【记录】idea创建springboot多模块项目

创建maven项目后删除src文件目录
【记录】idea创建springboot多模块项目_第1张图片
pom.xml文件修改如下:


<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>

    <groupId>org.bq8023groupId>
    <artifactId>springboot-activemqartifactId>
    <version>1.0-SNAPSHOTversion>
    
    
    <name>springboot-activemqname>
    <packaging>pompackaging>
	

    <properties>
        <maven.compiler.source>8maven.compiler.source>
        <maven.compiler.target>8maven.compiler.target>
    properties>

project>

右键项目名,选择新建 Module
【记录】idea创建springboot多模块项目_第2张图片
【记录】idea创建springboot多模块项目_第3张图片

新建 Module成功后,父依赖pom.xml会自动注册新创建的Module。代码如下:


<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>

    <groupId>org.bq8023groupId>
    <artifactId>springboot-activemqartifactId>
    <version>1.0-SNAPSHOTversion>
    
    <modules>
        <module>queue-customermodule>
    modules>

    <name>springboot-activemqname>
    <packaging>pompackaging>

    <properties>
        <maven.compiler.source>8maven.compiler.source>
        <maven.compiler.target>8maven.compiler.target>
    properties>

project>

依赖管理

有两种依赖管理方式,①使用,②使用

方案一:

依赖管理方式一:一级父项目pom.xml
父项目相当于一个依赖发布工厂,父项目统一管理依赖版本
子项目中需要的依赖,需在子项目中手动指定引入,无需指定依赖版本,无法继承父项目依赖直接使用。

    
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-starter-webartifactId>
                <version>${springboot.version}version>
            dependency>
        dependencies>
    dependencyManagement>

方案二:

子项目无需手动指定依赖引入,会自动继承父依赖直接使用。

	<dependencies>
            <dependency>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-starter-webartifactId>
                <version>${springboot.version}version>
            dependency>
        dependencies>

你可能感兴趣的:(Java,1024程序员节)