maven 构建 SpringBoot 多模块开发

#Idea maven 构建项目多模块开发手册

构建maven顶级项目

1

2

3

4

在顶级项目中构建多模块

1

2

3

4

5

6

7 聚合工程pom



  4.0.0
  pub.lgo
  TAOZUI
  1.0-SNAPSHOT
  pom

  TAOZUI
  
  http://www.example.com

  
    UTF-8
    1.7
    1.7
  

  
  
    tz-font
    tz-login
  
  
  
    
      
      
        org.springframework.boot
        spring-boot-dependencies
        2.1.3.RELEASE
        pom
        import
      
    
  

  
    
      junit
      junit
      4.11
      test
    
  

  
    
      
        
        
          maven-clean-plugin
          3.1.0
        
        
        
          maven-resources-plugin
          3.0.2
        
        
          maven-compiler-plugin
          3.8.0
        
        
          maven-surefire-plugin
          2.22.1
        
        
          maven-jar-plugin
          3.0.2
        
        
          maven-install-plugin
          2.5.2
        
        
          maven-deploy-plugin
          2.8.2
        
        
        
          maven-site-plugin
          3.7.1
        
        
          maven-project-info-reports-plugin
          3.0.0
        
      
    
  

8 font子工程pom



    4.0.0
    pub.lgo
    tz-font
    0.0.1-SNAPSHOT
    tz-font
    Demo project for Spring Boot
    
        11
    

    
    
        pub.lgo
        TAOZUI
        1.0-SNAPSHOT
    

    
        
            org.springframework.boot
            spring-boot-starter-web
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

9 login子工程pom



    4.0.0
    pub.lgo
    tz-login
    0.0.1-SNAPSHOT
    tz-login
    Demo project for Spring Boot
    
        11
    

    
    
        pub.lgo
        TAOZUI
        1.0-SNAPSHOT
    

    
        
            org.springframework.boot
            spring-boot-starter-web
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    
    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

重述

1 聚合工程pom需要聚合子工程使用modules标签

2 聚合工程pom需要为子工程继承项目相关依赖
springboot文档中给出的方案使用spring-boot-dependencies解决
官网: https://docs.spring.io/spring-boot/docs/1.4.3.RELEASE/reference/htmlsingle/#using-boot-maven-without-a-parent

3 子工程必须继承聚合工程

问题

maven命令报错

原因是顶级工程打包类型,因为顶级工程只为了传递依赖和聚合子工程,项目中没有java代码,
pom的packaging类型默认是jar类型,在此只需要将聚合工程里的packaging类型修改为pom

springboot项目启动闪退

Process finished with exit code 0
应该是忘了添加spring-boot-starter-web依赖

你可能感兴趣的:(Maven)