maven笔记
用了许久的maven,但仍然缺乏研究。
1、插件:在pom.xml中进行配置,可以在maven窗口中控制plugins的行为。
- assembly:可以连带着将所有依赖的jar都打包成一个大的jar包,在build下放置plugins。
<plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <configuration> <!-- get all project dependencies --> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <!-- MainClass in mainfest make a executable jar --> <archive> <manifest> <mainClass>App.main</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <!-- bind to the packaging phase --> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins>
- deploy:将打好的jar包发布到maven私服(Lifecycle下的deploy进行执行):注意plugins和plugManagement的区别
- 配置pom文件
<distributionManagement> <repository> <id>reponame-nexus-release</id> <url> http://remoteSrv/nexus/repository/reponame/ </url> </repository> <snapshotRepository> <id>reponame-nexus-snapshot</id> <url> http://remoteSrv/nexus/repository/reponame/ </url> </snapshotRepository> </distributionManagement>
- 配置~/.m2/settings.xml文件
<servers> <server> <id>reponame-nexus-snapshot</id> <username>user.can.upload</username> <password>password</password> </server> <server> <id>reponame-nexus-release</id> <username>user.can.upload</username> <password>password</password> </server> </servers>
- 配置pom文件
2、