首页 > 编程语言 > 详细

maven父子工程 + springboot

时间:2019-05-09 16:44:19      阅读:248      评论:0      收藏:0      [点我收藏+]

1,首先 单个的 springboot 工程会建技术分享图片

可以一直下一步

需要四个工程(左右)

2,如图 这四个就是我建的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

原文:https://www.cnblogs.com/liuqihu/p/10839266.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!