我正在使用 Maven-tomcat 插件。然而,要开始战争,它需要某些罐子。我已将这些 jars 签入到我们的 nexus 服务器,并将其作为依赖项添加到 maven tomcat 插件中 - 但是,当我运行 mvn tomcat6:run 时,构建失败。maven tomcat 插件试图在中央存储库中而不是在我的 nexus 服务器中找到依赖的 jar。有没有办法指定它应该查看哪个存储库?或者有什么方法可以为包含必要的附加 jars 的 maven-tomcat 插件指定一个文件夹?我尝试了所有选项,例如 classesDir 和 additionalClasspathDirs 但无济于事。任何帮助将不胜感激。
2 回答
I typically set up my companies nexus server as a repository in my global settings.xml thusly:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<profiles>
<profile>
<id>repositories</id>
<repositories>
<repository>
<id>my-nexus</id>
<name>My Nexus</name>
<url>http://my.company.com/nexus/content/groups/public</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
...
<activeProfiles>
<activeProfile>repositories</activeProfile>
</activeProfiles>
</settings>
Then it will be found by all my projects. If you do not control your gloabl settings, user settings will do just fine as well.
--------------- EDIT -----------------
I just realized this is asking about dependencies for the tomcat plugin... Plugins pull their dependencies from a different set of repositories specified by the <pluginRepositories>
element. So, you would need something like this:
<pluginRepositories>
<pluginRepository>
<id>my-nexus</id>
<name>My Nexus</name>
<url>http://my.company.com/nexus/content/groups/public</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
I tried finding good documentation on this, but its kinda glossed over in the maven docs. There is a similar question found here:
当您添加插件依赖项 (AFAIC)。
您必须在 pluginRepositories/pluginRepository 部分添加这个新的 repo。
高温高压