Could not find artifact com.sun:tools:jar:1.7 [duplicate]

这一生的挚爱 提交于 2021-02-09 10:52:53

问题


Here is my pom.xml

<project ... >
<modelVersion>4.0.0</modelVersion>

<groupId>io.fabric8</groupId>
<artifactId>kubernetes-alexa</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>


<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

    <!-- lambda -->
    <lambda.functionCode>${project.build.directory}/${project.build.finalName}.jar</lambda.functionCode>
    <lambda.version>${project.version}</lambda.version>
    <lambda.publish>true</lambda.publish>
    <lambda.forceUpdate>true</lambda.forceUpdate>

    <!-- versions -->
    <alexa-skills-kit.version>1.3.1</alexa-skills-kit.version>
    <junit.version>4.12</junit.version>
    <kubernetes-client.version>2.5.1</kubernetes-client.version>
    <sundrio.version>0.8.2</sundrio.version>

    <!-- plugin versions -->
    <lambda-maven-plugin.version>2.2.2</lambda-maven-plugin.version>

</properties>

<dependencyManagement>
    <dependencies>
        <!-- We are importing the kuberntes-client bom with deps to prevent jackson conflicts -->
        <dependency>
            <groupId>io.fabric8</groupId>
            <artifactId>kubernetes-client</artifactId>
            <version>${kubernetes-client.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>

    <dependency>
        <groupId>io.fabric8</groupId>
        <artifactId>openshift-client</artifactId>
        <version>${kubernetes-client.version}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.amazon.alexa/alexa-skills-kit -->

"pom.xml" 148L, 5831C

deploy command :

mvn clean package shade:shade com.github.seanroy:lambda-maven-plugin:deploy-lambda

Error while deploying the maven:

Logs :

Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.sun:tools:jar:1.7 at specified path /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/../lib/tools.jar
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:264)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:224)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:338)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve (DefaultProjectDependenciesResolver.java:202)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:243)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:246)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:200)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException



**Error :** Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.sun:tools:jar:1.7 at specified path

Note : Running on MacOS


回答1:


Short Answers :

<dependency>
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <version>3.1.8</version>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>                    
        </exclusion>
    </exclusions>            
</dependency>

--

Longer version. in order to track the artefact that has link to tools.jar, I use mvn dependency:tree it display the dependency:tree, therefore you can find which artifactId should have an exclusions.

ATTENTION, this can have side effect, testing is mandatory.

Hope this help

In my case :

$ mvn dependency:tree  | grep -B 10  -A 1 tools.jar

[INFO] +- io.fabric8:kubernetes-server-mock:jar:3.1.8:test
[INFO] |  \- io.fabric8:mockwebserver:jar:0.1.0:test
[INFO] |     +- com.squareup.okhttp3:mockwebserver:jar:3.9.0:test
[INFO] |     |  \- org.bouncycastle:bcprov-jdk15on:jar:1.50:test
[INFO] |     \- io.sundr:builder-annotations:jar:0.2.7:test
[INFO] |        +- io.sundr:sundr-core:jar:0.2.7:test
[INFO] |        +- io.sundr:sundr-codegen:jar:0.2.7:test
[INFO] |        |  \- org.apache.velocity:velocity:jar:1.7:test
[INFO] |        |     +- commons-collections:commons-collections:jar:3.2.1:test
[INFO] |        |     \- commons-lang:commons-lang:jar:2.4:test
[INFO] |        \- com.sun:tools:jar:1.7:system
[INFO] +- org.apache.commons:commons-lang3:jar:3.4:compile

so I set my pom.xml with :

    <dependency>
        <groupId>io.fabric8</groupId>
        <artifactId>kubernetes-server-mock</artifactId>
        <version>3.1.8</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>com.sun</groupId>
                <artifactId>tools</artifactId>                    
            </exclusion>
        </exclusions>            
    </dependency>


来源:https://stackoverflow.com/questions/51503460/could-not-find-artifact-com-suntoolsjar1-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!