日期:2014-05-18  浏览次数:20758 次

本地 搭建maven结构的J2EE项目(无需本地搭建私服)总结

最近在公司里面搭了个框架用起来还是不错的,所以想整回家把环境搭起来日后慢慢优化...

框架采用maven结构进行管理的...在公司里面有专门的私服,配置起来比较方便,回到家我想不搭私服了吧,直接用网络上现成的私服:发现了Nexus:https://code.lds.org/nexus

于是就想直接把maven的settings.xml更改下发现有些包还是找不到,当所有jar包都找到之后但是例如有些数据库的最新的驱动等可能在线的私服没有需要手动放到本地的资源库中,也就是数据库的驱动,在次过程中遇到一个问题;build项目的时候一直报一个错:

is missing, no dependency information available
[WARNING] The POM for
... is missing, no dependency information available

?最终发现一个国外的朋友也遇到过此类问题,然后热心的网友回答了他的问题:

http://cocoon.10839.n7.nabble.com/mvn-clean-install-failure-quot-Could-not-resolve-dependencies-quot-td11041.html

?

最终问题解决...

?

下面留下配置文件做记录:

.m2/settings.xml内容:

镜像中的配置:

 <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
	 <mirror>
      <id>nexus</id>
      <url>https://code.lds.org/nexus/content/groups/approved-group/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
	 <mirror>
      <id>nexus2</id>
      <url>https://code.lds.org/nexus/content/repositories/central/</url>
      <mirrorOf>external:*,!central</mirrorOf>
    </mirror>
	 
  </mirrors>

?

profiles中的配置:

<profile>
		<id>nexus</id>
		<repositories>
			<repository>
				<id>central</id>
				<url>http://central</url>
				<releases>
					<enabled>true</enabled>
				</releases>
				<snapshots>
					<enabled>true</enabled>
					<!--
					<updatePolicy>always</updatePolicy>
					-->
					<!--
					<checksumPolicy>ignore</checksumPolicy>
					-->
				</snapshots>
			</repository>
		</repositories>
		<pluginRepositories>
			<pluginRepository>
				<id>central</id>
				<url>http://central</url>
				<releases>
					<enabled>true</enabled>
				</releases>
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</pluginRepository>
		</pluginRepositories>
	</profile>

?

?

其中pom文件中需要配置:

<repositories>
    <repository>
      <id>maven2-repository.java.net</id>
      <name>Java.net Repository for Maven</name>
      <url>http://download.java.net/maven/2/</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>apache.snapshots</id>
      <name>Apache Snapshot Repository</name>
      <url>http://repository.apache.org/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
    </repository>
  </repositories>

?

?