Could not find artifact jdk.tools:jdk.tools:jar:1.6

167.6 [ERROR] Failed to execute goal on project module-common: Could not resolve dependencies for project com.wright:module-common:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: jdk.tools:jdk.tools:jar:1.6: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path /usr/lib/jvm/java-21-amazon-corretto/../lib/tools.jar -> [Help 1]
167.6 [ERROR] 
167.6 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
167.6 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
167.6 [ERROR] 
167.6 [ERROR] For more information about the errors and possible solutions, please read the following articles:
167.6 [ERROR] [Help 1] <http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException>
167.6 [ERROR] 
167.6 [ERROR] After correcting the problems, you can resume the build with the command
167.6 [ERROR]   mvn <args> -rf :module-common

解决方法

hadoop-common中依赖jdk.tools,去除掉


<dependency> 
  <groupId>org.apache.hadoop</groupId>  
  <artifactId>hadoop-common</artifactId>  
  <version>2.7.5</version>  
  <exclusions> 
    <exclusion> 
      <artifactId>jdk.tools</artifactId>  
      <groupId>jdk.tools</groupId> 
    </exclusion> 
  </exclusions>  
  <scope>provided</scope> 
</dependency>

如果有用到 baidusdk,里面以来了 hadoop cron-hadoop-coom,直接排除的 jdk tools 即可

<dependency>
            <groupId>com.baidubce</groupId>
            <artifactId>bce-java-sdk</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-reload4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>jdk.tools</artifactId>
                    <groupId>jdk.tools</groupId>
                </exclusion>
            </exclusions>
        </dependency>