如何修改settings.xml,以便如果本地不存在依赖项,请从Internet获得它

时间:2018-10-24 07:36:15

标签: maven maven-3 maven-plugin

我已经使用maven 3.3来构建项目。在这里,我们使用本地Maven存储库。 这是settings.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
      <id>central</id>
    </server>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
      <id>snapshots</id>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <mirrorOf>central</mirrorOf>
      <name>mirrorOfmaven</name>
      <url>http://10.2.2.29:8080/artifactory/mirrorOfmaven</url>
      <id>mirrorOfmaven</id>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <repositories>      
        <repository>
          <id>ext-release-local</id>
          <name>ext-release-local</name>
          <url>http://10.2.2.29:8080/artifactory/ext-release-local</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>   
        <repository>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>libs-release-local</id>
          <name>libs-release-local</name>
          <url>http://10.2.2.29:8080/artifactory/libs-release-local</url>
        </repository>       
      </repositories>      
      <id>artifactory</id>
    </profile>
    <profile>
        <id>local</id>
        <activation>
        <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
        <build.profile.id>local</build.profile.id>
        <wls.adminurl>t3://localhost:7001</wls.adminurl>
        <wls.username>weblogic</wls.username>
        <wls.password>weblogic</wls.password>
        <wls.targets>artserver</wls.targets>
        </properties>
    </profile>
    <profile>
        <id>prod</id>
        <properties>
        <build.profile.id>prod</build.profile.id>
        </properties>
    </profile>
    <profile>
        <id>test</id>
        <properties>
        <build.profile.id>test</build.profile.id>
        </properties>
    </profile>

  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

现在我需要使用Maven jaxb2插件,

 <groupId>org.jvnet.jaxb2.maven2</groupId>
 <artifactId>maven-jaxb2-plugin</artifactId>
 <version>${maven-jaxb2-plugin.version}</version>

在我的本地存储库中不存在。

运行时会提示错误

Failure to find org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:jar:0.13.3 in http://10.2.2.29:8080/artifactory/mirrorOfmaven was cached in the local repository

如何修改settings.xml,以便如果本地不存在依赖项,请从Internet获取它。

0 个答案:

没有答案