Maven常用配置

pom.xml配置示例

以下是一个比较精简的spring-boot项目的配置文件,包含了Swagger和Jacoco插件。



  4.0.0

  com.foo
  bar
  0.0.1-SNAPSHOT
  jar

  bar
  blablabla

  
    org.springframework.boot
    spring-boot-starter-parent
    1.4.6.RELEASE
    
  

  
    UTF-8
    UTF-8
    1.8
    Dalston.RELEASE
    1.8

    
    x.x.x.x
    /
    bar
    v1
    com.foo.bar.web
    ${basedir}/target
    swagger
  

  
  
    
    
      org.springframework.boot
      spring-boot-starter
    
    
      org.springframework.boot
      spring-boot-starter-web
    
    
      org.springframework.boot
      spring-boot-starter-test
    
    
      org.springframework.boot
      spring-boot-starter-actuator
    
    
      org.springframework.boot
      spring-boot-configuration-processor
      true
    
    
      org.springframework.cloud
      spring-cloud-starter-hystrix
    
    
      org.springframework.cloud
      spring-cloud-starter-hystrix-dashboard
    

    
    
      io.springfox
      springfox-swagger2
      2.7.0
    
    
      io.springfox
      springfox-swagger-ui
      2.7.0
    
  

  
    
      
        org.springframework.cloud
        spring-cloud-dependencies
        Brixton.SR5
        pom
        import
      
    
  

  
    
      
        org.springframework.boot
        spring-boot-maven-plugin
      
      
        org.apache.maven.plugins
        maven-jar-plugin
        2.6
        
          
            
              true
              lib/
              com.foo.bar.Application
            
          
        
      
      
      
        com.github.kongchen
        swagger-maven-plugin
        3.1.4
        
          
            
              true
              
                ${location}
              
              
                http
                https
              
              ${host}
              ${basepath}
              
                ${mainTitle}
                ${mainVersion}
              
              ${swaggerDirectory}
              ${swaggerFileName}
            
          
        
        
          
            compile
            
              generate
            
          
        
      
      
      
        org.apache.maven.plugins
        maven-surefire-plugin
        2.12.4
        
          false
          ${surefireArgLine}
        
      
      
        org.jacoco
        jacoco-maven-plugin
        0.7.7.201606060606
        
          
            default-prepare-agent
            
              prepare-agent
            
            
              
                ${project.build.directory}/coverage-reports/jacoco.exec
              
              surefireArgLine
            
          
        
      
    
  

settings.xml配置示例

以下是一个使用nexus时的settings.xml配置文件示例




    
    

    
        
            nexus-releases
            admin
            foobar
        
        
            nexus-snapshots
            admin
            foobar
        
    

    
        
            nexus-releases
            *
            http://x.x.x.x:8081/nexus/content/groups/public
        
        
            nexus-snapshots
            *
            http://x.x.x.x:8081/nexus/content/groups/public-snapshots
        
    

    
        
            nexus
            
                
                    nexus-releases
                    http://nexus-releases
                    
                        true
                    
                    
                        true
                    
                
                
                    nexus-snapshots
                    http://nexus-snapshots
                    
                        true
                    
                    
                        true
                    
                
            
            
                
                    nexus-releases
                    http://nexus-releases
                    
                        true
                    
                    
                        true
                    
                
                
                    nexus-snapshots
                    http://nexus-snapshots
                    
                        true
                    
                    
                        true
                    
                
            
        
    

    
        nexus
    


清理脚本

当maven下载依赖时,如果网络中断,会产生一些.lastUpdated文件,导致下次无法正常下载依赖,以下是一个简单的清理脚本

cd ~/.m2
find . -name "*.lastUpdated" -exec rm -rf {} \;

你可能感兴趣的:(Maven常用配置)