maven父子工程 + springboot

1,首先 单个的 springboot 工程会建maven父子工程  +  springboot

可以一直下一步

需要四个工程(左右)

2,如图 这四个就是我建的springboot工程

maven父子工程  +  springboot

 

  将parent_house 工程中的 src 文件夹删除

  domain_house  和 service_house 工程的 src   里面的 java文件夹和resource 文件夹 里面的东西删掉

  web_house 里面可以不用动

3,配置文件

  parent 配置文件

  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.house.demo</groupId>
    <artifactId>parenter_house</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>parenter_house</name>
    <packaging>pom</packaging>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <modules>
        <module>../web_house</module>
        <module>../domain_house</module>
        <module>../service_house</module>
    </modules>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <configuration>
                    <skipTests>true</skipTests>    <!--默认关掉单元测试 -->
                </configuration>
            </plugin>
        </plugins>
    </build>

  domain  配置文件

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.house.demo</groupId>
    <artifactId>domain_house</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>domain_house</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

  service 配置文件

  <parent>
        <groupId>com.house.demo</groupId>
        <artifactId>parenter_house</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>pom.xml</relativePath>

    </parent>


    <groupId>com.house.demo</groupId>
    <artifactId>service_house</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>service_house</name>
    <packaging>jar</packaging>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.house.demo</groupId>
            <artifactId>domain_house</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-core</artifactId>
        </dependency>
    </dependencies>

  web配置文件

  <parent>
        <groupId>com.house.demo</groupId>
        <artifactId>parenter_house</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>pom.xml</relativePath>
    </parent>

    <groupId>com.house.demo</groupId>
    <artifactId>web_house</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>web_house</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.house.demo</groupId>
            <artifactId>service_house</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.house.demo</groupId>
            <artifactId>domain_house</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
    </dependencies>

    <!--spring boot打包的话需要指定一个唯一的入门-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <!-- 指定该Main Class为全局的唯一入口 -->
                    <mainClass>com.example.WebApplication</mainClass>
                    <layout>ZIP</layout>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

虽然都是springboot 工程  pom  文件中 配置父子关系,及依赖关系

还需要自己去调包结构

以及controller 里面的方法

maven父子工程  +  springboot

 

上一篇:独立的小易


下一篇:LeetCode 198. 打家劫舍(House Robber)