成都创新互联网站制作重庆分公司

Springboot源码怎么分析项目结构

Springboot源码怎么分析项目结构,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

创新互联科技有限公司专业互联网基础服务商,为您提供成都机柜租用高防主机,成都IDC机房托管,成都主机托管等互联网服务。

Springboot源码分析之项目结构

摘要:
  • 无论是从IDEA还是其他的SDS开发工具亦或是https://start.spring.io/ 进行解压,我们都会得到同样的一个pom.xml文件 4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.6.RELEASE

        com.github.dqqzj
        springboot
        0.0.1-SNAPSHOT
        springboot
        jar
        Demo project for Spring Boot
    
        
            1.8
        
    
        
            
                org.springframework.boot
                spring-boot-starter
            
            
                org.springframework.boot
                spring-boot-starter-test
                test
            
        
    
        
            
                
                    org.springframework.boot
                    spring-boot-maven-plugin
                
            
        
    
    

parent标签的含义
  • 找到本地仓库的spring-boot-starter-parent 坐标

    4.0.0
    
      org.springframework.boot
      spring-boot-dependencies
      2.1.6.RELEASE
      ../../spring-boot-dependencies
    
    spring-boot-starter-parent
    pom
    Spring Boot Starter Parent
    Parent pom providing dependency and plugin management for applications
                  built with Maven
    https://projects.spring.io/spring-boot/#/spring-boot-starter-parent
    
      UTF-8
      1.8
      @
      ${java.version}
      UTF-8
      ${java.version}
    
    
      
        
          true
          ${basedir}/src/main/resources
          
            **/application*.yml
            **/application*.yaml
            **/application*.properties
          
        
        
          ${basedir}/src/main/resources
          
            **/application*.yml
            **/application*.yaml
            **/application*.properties
          
        
      
      
        
          
            org.jetbrains.kotlin
            kotlin-maven-plugin
            ${kotlin.version}
            
              
                compile
                compile
                
                  compile
                
              
              
                test-compile
                test-compile
                
                  test-compile
                
              
            
            
              ${java.version}
              true
            
          
          
            maven-compiler-plugin
            
              true
            
          
          
            maven-failsafe-plugin
            
              
                
                  integration-test
                  verify
                
              
            
            
              ${project.build.outputDirectory}
            
          
          
            maven-jar-plugin
            
              
                
                  ${start-class}
                  true
                
              
            
          
          
            maven-war-plugin
            
              
                
                  ${start-class}
                  true
                
              
            
          
          
            org.codehaus.mojo
            exec-maven-plugin
            
              ${start-class}
            
          
          
            maven-resources-plugin
            
              
                ${resource.delimiter}
              
              false
            
          
          
            pl.project13.maven
            git-commit-id-plugin
            
              
                
                  revision
                
              
            
            
              true
              yyyy-MM-dd'T'HH:mm:ssZ
              true
              ${project.build.outputDirectory}/git.properties
            
          
          
            org.springframework.boot
            spring-boot-maven-plugin
            
              
                repackage
                
                  repackage
                
              
            
            
              ${start-class}
            
          
          
            maven-shade-plugin
            
              
                package
                
                  shade
                
                
                  
                    
                      META-INF/spring.handlers
                    
                    
                      META-INF/spring.factories
                    
                    
                      META-INF/spring.schemas
                    
                    
                    
                      ${start-class}
                    
                  
                
              
            
            
              
                org.springframework.boot
                spring-boot-maven-plugin
                2.1.6.RELEASE
              
            
            
              true
              true
              
                
                  *:*
                  
                    META-INF/*.SF
                    META-INF/*.DSA
                    META-INF/*.RSA
                  
                
              
            
          
          
            org.eclipse.m2e
            lifecycle-mapping
            1.0.0
            
              
                
                  
                    
                      org.codehaus.mojo
                      flatten-maven-plugin
                      [1.0.0,)
                      
                        flatten
                      
                    
                    
                      
                    
                  
                  
                    
                      org.apache.maven.plugins
                      maven-checkstyle-plugin
                      [3.0.0,)
                      
                        check
                      
                    
                    
                      
                    
                  
                
              
            
          
        
      
    

关注点
    
        org.springframework.boot
        spring-boot-dependencies
        2.1.6.RELEASE
        ../../spring-boot-dependencies
      
    ```

说明我们的工程可以进行改造进行替换掉原来工程的`parent`标签.

-     
                org.springframework.boot
                spring-boot-maven-plugin
                
                  
                    repackage
                    
                      repackage
                    
                  
                
                
                  ${start-class}
                
              
 ` repackage`必须要有否则打jar包时候无法正常启动.
 ![file](/upload/otherpic49/779545.jpg)

在配置文件加上`repackage`即可

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

`IDEA`自带`maven`工具

![file](/upload/otherpic49/779546.jpg)

`mvnw`是基于`linux`的`shell`脚本命令

`mvnw.cmd`是基于`windows`的脚本命令

`.mvn`包含了` maven`下载路径以及版本等信息

也就是说我们完全不用自己下载`maven`而是可以直接使用`IDEA`给我们提供的工具即可,只不过通常不会这么做。
#### `repackage`的作用

- [官方文档](https://docs.spring.io/spring-boot/docs/current/maven-plugin/repackage-mojo.html)
- 正常情况下打包会生成`springboot-0.0.1-SNAPSHOT.jar`,`original,springboot-0.0.1-SNAPSHOT.jar`这样的2个文件,而`repackage`的作用就是将`springboot-0.0.1-SNAPSHOT.jar.original`重新打包为我们可以执行的`springboot-0.0.1-SNAPSHOT.jar`

关于Springboot源码怎么分析项目结构问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。


标题名称:Springboot源码怎么分析项目结构
URL地址:http://cxhlcq.com/article/goscss.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部