maven 配置多个仓库

方法一

  • Maven 的 settings.xml 内的 mirror 节点:
<mirrors>
    <mirror>
        <id>alimavenid>
        <name>aliyun mavenname>
        <url>http://maven.aliyun.com/nexus/content/groups/public/url>
        <mirrorOf>centralmirrorOf>
    mirror>
mirrors>

<mirrors>
    <mirror>
        <id>mynexusid>
        <name>mynexus mavenname>
        <url>http://10.0.1.189:8081/repository/dilu-releaseurl>
        <mirrorOf>centralmirrorOf>
    mirror>
mirrors>
  • 但是上面的方式不生效,所以需要这样
<profiles>
    <profile>
      <id>boundlessgeoid> 
      <repositories>
        <repository>
          <id>boundlessgeoid> 
          <url>https://repo.boundlessgeo.com/main/url> 
          <releases>
            <enabled>trueenabled>
          releases> 
          <snapshots>
            <enabled>trueenabled> 
            <updatePolicy>alwaysupdatePolicy>
          snapshots>
        repository>
      repositories>
    profile>
    <profile>
      <id>aliyunid> 
      <repositories>
        <repository>
          <id>aliyunid> 
          <url>http://maven.aliyun.com/nexus/content/groups/public/url> 
          <releases>
            <enabled>trueenabled>
          releases> 
          <snapshots>
            <enabled>trueenabled> 
            <updatePolicy>alwaysupdatePolicy>
          snapshots>
        repository>
      repositories>
    profile> 
    <profile>
      <id>maven-centralid> 
      <repositories>
        <repository>
          <id>maven-centralid> 
          <url>http://central.maven.org/maven2/url> 
          <releases>
            <enabled>trueenabled>
          releases> 
          <snapshots>
            <enabled>trueenabled> 
            <updatePolicy>alwaysupdatePolicy>
          snapshots>
        repository>
      repositories>
    profile>
<profiles>

并通过配置 activeProfiles 子节点激活

<activeProfiles>
    <activeProfile>boundlessgeoactiveProfile>
    <activeProfile>aliyunactiveProfile>
    <activeProfile>maven-centralactiveProfile>
activeProfiles>

方法二

  • pom文件的repositories节点
<repositories>
	<repository>
		<id>mynexusid>
		<name>nexus public repositoriesname>
		<url>http://10.0.1.189:8081/repository/dilu-release/url>
	repository>
	<repository>
		<id>alimavenid>
		<name>aliyun mavenname>
		<url>http://maven.aliyun.com/nexus/content/groups/public/url>
	repository>
repositories>

你可能感兴趣的:(开发,maven)