maven 私服(nexus)架设以及项目管理中遇到的问题及解决方案(updating)

---    用maven 的过程中 大问题小问题实在是不少 ,就不一篇文章一篇文章的写了,干脆写在一起 ----

-------  nexus 加索引

 点击Administration菜单下面的Repositories,将这三个仓库Apache Snapshots,Codehaus Snapshots,Maven Central的configuration下的remote repository access 下的 Download Remote Indexes修改为true。然后在这三个仓库上分别右键,选择Re-index,这样Nexus就会去下载远程的索引文件。 

(这里注意:reindex后,nexus只会把索引下载下来,而不是jar本身。只有当你运行项目时,才会真正根据索引下载相应的jar并放在 C:\Documents and Settings\localUser\sonatype-work\nexus\storage\ 下面。--当然同时,这些jar 也会下载到本地机器的.m2 工作仓库下。)

------- maven 生成eclipse 项目时报的错

[INFO] Resource directory's path matches an existing source directory. Resources
will be merged with the source directory src/main/resources
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR

 可能会产生以上错误  在pom 文件中巴maven-eclipse-plugin 这样引入:

<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-eclipse-plugin</artifactId>
				<version>2.6</version>
				<configuration>
					<wtpmanifest>true</wtpmanifest>
					<wtpapplicationxml>true</wtpapplicationxml>
					<wtpversion>2.0</wtpversion>
				</configuration>
			</plugin>

 搞定。  (之前的问题是由于plugin 的版本引起的 改成2.6 就行了。)

-------   maven 部署到weblogic 上时可能出现内存溢出

[INFO] Java heap space
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.OutOfMemoryError: Java heap space

 解决方案:在环境变量设置 MAVEN_OPTS=-Xms128m -Xmx512m     ---- 啊? 还有错么? 那就是机器内存不够啦 重启一下吧.....

----------   maven weblogic 插件的所有操作

http://maven-plugins.sourceforge.net/maven-weblogic-plugin/goals.html

----------    关于M2_REPO

这个问题还纠结了一阵子,记得以前配置的时候在eclipse中加M2_REPO变量后就能把仓库的jar加到eclipse中,但突然不好使了,后来不得不靠m2eclipse插件帮忙。 今天突然开窍.. 没在机器环境变量里配M2_REPO变量.....配置上后问题得以解决(卸载掉m2eclipse..)

----------    maven 解决嵌套依赖产生的冲突

比如说:jbpm 的依赖里面又做了对hibernate 的依赖 其pom里面引入了hibernate-core 等hibernate 的包,而项目又不能因为用jbpm对hibernate 的引入而删除本身项目对hibernate 的引入,因此为了避免重复引入造成的冲突,只能把jbpm对hibernate 的引入删去,这里只需要对pom 进行一个exclusion 就行了! 首先打开相应目录下的jbpm 的pom 看看其对hibernate 引入的groupId 和 artifactId 然后再在相应的jar 上面移除这两个依赖 写法如下:

<dependency>
			<groupId>org.jbpm.jbpm4</groupId>
			<artifactId>jbpm-pvm</artifactId>
			<version>4.3</version>
			<exclusions>
				<exclusion>
					<groupId>org.hibernate</groupId>
					<artifactId>hibernate-core</artifactId>
				</exclusion>
				<exclusion>
					<groupId>javassist</groupId>
					<artifactId>javassist</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

这样  移除了jbpm 下对hibernate 和javassist 的依赖  为了避免冲突。

----------    修改nexus工作目录

参照:http://marshal.easymorse.com/archives/1195

----------    用maven打包 maven war   (mvn war:war) 插件。

<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-war-plugin</artifactId>
			<version>2.1-alpha-1</version>
			<configuration>
				<!--
					打包之前过滤掉不想要被打进 .war包的jar,注意:这个地方,本来路径应该是
					WEB-INF/lib/anaalyzer-2.0.4.jar,但是经过多次试验,不能这样,至于咋回事儿,搞不清楚。。经多方查证均无结果
					暂且这样吧,虽然显得很丑陋,但是总能解决问题吧
				-->
				<warSourceExcludes>*/lib/analyzer-2.0.4.jar</warSourceExcludes>
				<webResources>
					<resource>
						<!-- 元配置文件的目录,相对于pom.xml文件的路径 -->
						<directory>src/main/webapp/WEB-INF</directory>

						<!-- 是否过滤文件,也就是是否启动auto-config的功能 -->
						<filtering>true</filtering>

						<!-- 目标路径 -->
						<targetPath>WEB-INF</targetPath>
					</resource>
				</webResources>
			</configuration>
		</plugin>

 ---其实执行mvn:package就可以了 不用在pom 中配这么多..  maven 会把打的war包放在项目目录的target目录下。 而且我使用mvn  war:war 时 打的包出问题了 不知道为啥.. 后来用mvn package 就没问题。不知道大家有没有遇到过...

猜你喜欢

转载自cloudera.iteye.com/blog/644032