快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

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源码怎么分析项目结构
标题网址:http://6mz.cn/article/goscss.html

其他资讯