Spring Bootカスタムstarter-parent

5769 ワード

背景
私たちはSpring Bootプロジェクトを作る時に、建設したばかりの都市は父からのparentを引き継ぎます.
    
        org.springframework.boot
        spring-boot-starter-parent
        1.5.17.RELEASE
         
    
私たちは自分のparentをカスタマイズしたいです.以下のいくつかの理由があります.
  • は、私たち自身の開発仕様を定義します.カスタマイズされたparentで導入された依存性を規範化することができます.
  • は、開発効率を向上させます.一人一人が共通性の部分に関心を持たなくてもいいです.
  • 開始
    私たちはベントプロジェクトを作っています.私たちは父のポムですので、ポムファイルだけを残して、他のものは直接削除してもいいです.pomファイルの内容は以下の通りです.
    
    
    
      4.0.0
    
      com.example
      parent
      
      pom
      1.0-SNAPSHOT
      Self Parent Project
    
      
        org.springframework.boot
        spring-boot-starter-parent
        1.5.17.RELEASE
      
    
      
        UTF-8
        UTF-8
        UTF-8
        1.8
        3.4
      
    
      
        
          
            org.apache.commons
            commons-lang3
            ${commons-lang.version}
          
        
      
    
      
        ${project.artifactId}
        
          
            
            
              org.apache.maven.plugins
              maven-release-plugin
              
                
                true
                
                v@{project.version}
                false
                
                true
                true
                
                  .project
                  .settings
                  .classpath
                  **\.project
                  **\.settings
                  **\.classpath
                
                
              
              
                
                  org.apache.maven.scm
                  maven-scm-provider-gitexe
                  1.9.4
                
              
            
            
            
              org.apache.maven.plugins
              maven-source-plugin
              
                
                  
                    jar
                  
                
              
            
            
            
              org.apache.maven.plugins
              maven-enforcer-plugin
              3.0.0-M2
              
                
                  enforce-banned-dependencies 
                  
                    enforce 
                  
                  
                     
                       
                        
                          
                            commons-lang:commons-lang 
                          
                        
                      
                    
                    true 
                  
                
              
            
          
        
    
        
          
          
            org.apache.maven.plugins
            maven-enforcer-plugin
          
        
      
    
      
        
          Releases
          Local Nexus Repository
          http://192.168.1.177:8081/nexus/content/repositories/releases
        
        
          Snapshots
          Local Nexus Repository
          http://192.168.1.177:8081/nexus/content/repositories/snapshots
        
      
    
    
    
    
    ちょっと注意が必要です.
  • packagingタイプはpomに指定する必要があります.
  • 拡張
    上のPOMにはいくつかのMavenプラグインが使われています.
  • maven-enforcer-plugin:このプラグインの使用と紹介はこの記事を参照することができます.https://blog.csdn.net/wangjunjun2008/article/details/11599307