maven配置
来源:互联网 发布:sublime java插件 编辑:程序博客网 时间:2024/05/16 06:57
1.添加账号信息到setting.xml(maven/conf/setting.xml)
调用mvn deploy命令时会使用账号信息
<!-- servers | This is a list of authentication profiles, keyed by the server-id used within the system. | Authentication profiles can be used whenever maven must make a connection to a remote server. |--> <servers> <!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the 'id' attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. | <server> <id>deploymentRepo</id> <username>repouser</username> <password>repopwd</password> </server> --><server> <id>releases</id> <username>admin</username> <password>admin123</password></server><server> <id>thirdparty</id> <username>admin</username> <password>admin123</password></server><server> <id>snapshots</id> <username>admin</username> <password>admin123</password></server> <!-- Another sample, using keys to authenticate. <server> <id>siteServer</id> <privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave empty if not used.</passphrase> </server> --> </servers>
2.配置profile到setting文件
当依赖私库的jar包,用mvn package编译时,需要配置profile并开启
<profiles> <!-- profile | Specifies a set of introductions to the build process, to be activated using one or more of the | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/> | or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is to use a consistent naming convention | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. | This will make it more intuitive to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile id's for debug. | | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. <profile> <id>jdk-1.4</id> <activation> <jdk>1.4</jdk> </activation> <repositories> <repository> <id>jdk14</id> <name>Repository for JDK 1.4 builds</name> <url>http://www.myhost.com/maven/jdk14</url> <layout>default</layout> <snapshotPolicy>always</snapshotPolicy> </repository> </repositories> </profile> --> <!-- | Here is another profile, activated by the system property 'target-env' with a value of 'dev', | which provides a specific path to the Tomcat instance. To use this, your plugin configuration | might hypothetically look like: | | ... | <plugin> | <groupId>org.myco.myplugins</groupId> | <artifactId>myplugin</artifactId> | | <configuration> | <tomcatLocation>${tomcatPath}</tomcatLocation> | </configuration> | </plugin> | ... | | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to | anything, you could just leave off the <value/> inside the activation-property. | <profile> <id>env-dev</id> <activation> <property> <name>target-env</name> <value>dev</value> </property> </activation> <properties> <tomcatPath>/path/to/tomcat/instance</tomcatPath> </properties> </profile> --><profile> <id>localMaven</id> <!--Enable snapshots for the built in central repo to direct --> <!--all requests to nexus via the mirror --> <repositories> <repository> <id>maven-central</id> <url>http://10.9.4.250:9081/nexus/content/groups/public</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>maven-central</id> <url>http://10.9.4.250:9081/nexus/content/groups/public</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <!-- activeProfiles | List of profiles that are active for all builds. | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile> </activeProfiles> --> <activeProfiles> <!--make the profile active all the time --><activeProfile>localMaven</activeProfile> </activeProfiles>
3.pom文件需要添加私库的地址
<distributionManagement> <repository> <id>releases</id> <url>http://10.9.1.250:9081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>http://10.9.1.250:9081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
4.使用maven命令
mvn clean 清理上次编译的target缓存
mvn package 编译打包
mvn install 安装jar包本地仓库
mvn deploy 上传jar包到私库
使用-X输出日志,例如:mvn -X package
0 0
- 配置Maven
- maven配置
- 配置maven
- Maven配置
- Maven配置
- maven 配置
- maven 配置
- maven 配置
- maven 配置
- maven配置
- maven 配置
- maven 配置
- maven 配置
- 配置 maven
- maven 配置
- 配置maven
- maven配置
- 配置maven
- Web实现QQ第三方登录
- 【iOS自动约束】四个重要的系统方法
- SpringMVC学习3
- 实验楼Linux学习笔记(四)之环境变量与文件查找
- 我是一个目标不坚定的人
- maven配置
- 使用GPS经纬度定位附近地点(某一点范围内查询)
- Xml之pull解析
- 如何使用git工具向github提交代码
- 【贪心】CSU 1809 Parenthesis (2016湖南省第十二届大学生计算机程序设计竞赛)
- hls在HTML5页面中进行播放
- java微信公众号开发,文件上传
- day3_列表li
- 在数论中使用筛法