Maven嵌入器:无法解析编译器依赖性 - 没有可用的连接器工厂

时间:2015-02-07 17:32:10

标签: java maven

我有maven项目 A B 。项目 A 使用maven embedder 3.2.5并使用它构建项目 B

MavenCli mavenCli = new MavenCli();
mavenCli.doMain(new String[] {"package"}, "C:\\Users\\JohnDoe\\Desktop\\abc", System.out, System.out);

但我得到了例外:

  

插件org.apache.maven.plugins:maven-compiler-plugin:3.1或其中一个依赖项无法解析:无法读取org.apache.maven.plugins的工件描述符:maven-compiler-plugin:jar :3.1:无法传输工件org.apache.maven.plugins:maven-compiler-plugin:pom:3.1 from / to central(https://repo.maven.apache.org/maven2):没有可用的连接器工厂

我查看了我的本地存储库文件夹,确实没有插件版本3.1。如果我手动将它放在那里构建成功。但AFAIK maven会自动下载所有必要的插件。但它不会发生。

4 个答案:

答案 0 :(得分:5)

添加这些依赖项解决了我的问题

 <dependency>
  <groupId>org.eclipse.aether</groupId>
  <artifactId>aether-connector-basic</artifactId>
  <version>1.0.2.v20150114</version>
</dependency>
<dependency>
  <groupId>org.eclipse.aether</groupId>
  <artifactId>aether-transport-wagon</artifactId>
  <version>1.0.2.v20150114</version>
</dependency>
<dependency>
  <groupId>org.apache.maven.wagon</groupId>
  <artifactId>wagon-http</artifactId>
  <version>2.8</version>
  </dependency>
<dependency>
  <groupId>org.apache.maven.wagon</groupId>
  <artifactId>wagon-provider-api</artifactId>
  <version>2.8</version>
</dependency>

答案 1 :(得分:0)

如果要部署,还需要此依赖项:

<dependency
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.3</version>
</dependency>

答案 2 :(得分:0)

使用这些依赖项

<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-embedder</artifactId>
    <version>3.6.3</version>
</dependency>
<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-compat</artifactId>
    <version>3.6.3</version>
</dependency>
<dependency>
    <groupId>org.apache.maven.resolver</groupId>
    <artifactId>maven-resolver-connector-basic</artifactId>
    <version>1.4.1</version>
</dependency>
<dependency>
    <groupId>org.apache.maven.resolver</groupId>
    <artifactId>maven-resolver-transport-http</artifactId>
    <version>1.4.1</version>
</dependency>

使用Apache Maven Artifact Resolver代替已存档的Aether。

答案 3 :(得分:-1)

我将我的应用程序(Spring Boot 2.3,JDK8 / 11)更新为最新的Maven Embedded 3.6.3版本,具有以下依赖关系:

<!-- Maven Embedder -->
<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-embedder</artifactId>
    <version>3.6.3</version>
</dependency>
<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-compat</artifactId>
    <version>3.6.3</version>
</dependency>
<dependency>
    <groupId>org.apache.maven.wagon</groupId>
    <artifactId>wagon-http</artifactId>
    <version>3.3.4</version>
</dependency>
<dependency>
    <groupId>org.eclipse.aether</groupId>
    <artifactId>aether-connector-basic</artifactId>
    <version>1.1.0</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>org.eclipse.aether</groupId>
    <artifactId>aether-transport-wagon</artifactId>
    <version>1.1.0</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.30</version>
</dependency>

HTH