How to build nexus private server, and its use
1. Installation
1. Download the latest nexus installation package
Download address: http://www.sonatype.org/nexus/go
2. Run nexus.bat to install nexus service.
3. Start the service.
4. Access address: http://localhost:8081/nexus/
5. Default administrator: admin Password: admin123
6. Default deployment username: deployment Password: deployment123
7. The jar package and plug-in downloaded from the private server will also be in the local warehouse
Two, placement
The configuration in the pom is as follows, you can download packages and plug-ins from the private server
<project>
...
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.168.8.6:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.168.8.6:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
POM中配置如下,可调用
mvn命令:deploy到私服(同时需要修改setting.xml文件中配置部署用户名及密码)(ps:install是安装到本地仓库 deploy是部署到私服)
<project>
...
<!-- 部署到私服 -->
<distributionManagement>
<repository>
<id>emp-release</id>
<name>emp-vaadin-component-release</name>
<url>http://192.168.8.6:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>emp-snapshot</id>
<name>emp-vaadin-component-snapshot</name>
<url>http://192.168.8.6:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
setting.xml相应配置如下:
<server>
<id>emp-release</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>emp-snapshot</id>
<username>deployment</username>
<password>deployment123</password>
</server>
第二个问题与上面不同:
snapshot版本使用注意事项:
1、A、B工程在同一eclipse工作区中,A的pom中依赖了B.jar
若不在eclipse关闭B工程,A工程maven->update project时候 不会更新快照版本的jar 会直接引用工作区中的B工程,而非B.jar。
解决办法:将B工程,右键->close project。然后如图,update maven project 中勾选force update of snapshots/releases。这样工程就会自动下载最新的snapshot版本。
![](http://img.my.csdn.net/uploads/201212/31/1356939861_1071.png)
三、使用
详见《maven实战》(未完待续)
目录(?)[+]
Maven问题总结:Eclipse中项目右键菜单中点击Maven->Update Projects时JDK被重置
Eclipse中在项目右键菜单点击->Maven->Update Projects时,JDK总是切回 1.5
如果没有在Maven中配置过JDK版本,只是在Eclipse中项目的Properties配置里修改了Java版本,当运行Maven->Update Projects时,Java版本又会被切回默认的1.5。
编译器插件用来编译项目的源文件.从3.0版本开始, 用来编译Java源文件的默认编译器是javax.tools.JavaCompiler (如果你是用的是java 1.6) . 如果你想强制性的让插件使用javac,你必须配置插件选项 forceJavacCompilerUse. 同时需要注意的是目前source选项和target 选项的默认设置都是1.5, 与运行Maven时的JDK版本无关.如果你想要改变这些默认设置, 可以参考 Setting the -source and -target of the Java Compiler中的描述来设置 source 和target 选项.
运行Maven->Update Project时,会根据maven和pom.xml配置调用eclipse插件重建Eclipse工程文件(.project、.classpath和.settings)。因此Eclipse中的配置会被重置。
方式一: 可以修改项目的配置,指定编译使用的java版本。
如下配置pom.xml文件:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build>
方式二:配置Maven默认使用的JDK版本
%M2_HOME%/conf/settings.xml文件中加入如下配置:
<profiles> <profile> <id>jdk-1.6</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.6</jdk> </activation> <properties> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> <maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion> </properties> </profile> </profiles>