我是靠谱客的博主 爱笑石头,最近开发中收集的这篇文章主要介绍程序包sun.security.tools.keytool不存在问题解决,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Jdk 1.8使用import sun.security.tools.keytool.CertAndKeyGen;来生成证书,导致项目打包时报下面这个异常,程序包sun.security.tools.keytool不存在问题

[ERROR] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/CertService.java:[15,34] 程序包sun.security.tools.keytool不存在
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.824 s
[INFO] Finished at: 2020-01-04T14:22:06+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project webank-demo: Compilation failure
[ERROR] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/CertService.java:[15,34] 程序包sun.security.tools.keytool不存在
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:

解决

既然是找不到${Jdk}jrelibrt.jar,那我们在java home下面找到该jar包,将其放到我们的Maven私服上面去,然后再项目中依赖私服中的
rt.jar包该问题就解决啦。

   <!-- 我私服的地址 -->
    <repositories>
        <repository>
            <id>huluwa</id>
            <url>http://api.fangxinqian.cn:8081/repository/huluwa/</url>
        </repository>
    </repositories>
    <!-- 私服rt包的具体依赖 -->
    <dependency>
        <groupId>cn.fangxinqian</groupId>
        <artifactId>rt</artifactId>
        <version>1.0</version>
    </dependency>
fxqdeiMac:webank-demo fxq$ mvn clean install -DskipTests=true
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< cn.isuyu.webank:webank-demo >---------------------
[INFO] Building webank-demo 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ webank-demo ---
[INFO] Deleting /Users/fxq/Public/WorkSpace/webank-demo/target
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ webank-demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ webank-demo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to /Users/fxq/Public/WorkSpace/webank-demo/target/classes
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[23,25] sun.security.pkcs.ContentInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[24,25] sun.security.pkcs.PKCS7是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[25,25] sun.security.pkcs.SignerInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[26,25] sun.security.util.DerOutputStream是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[27,25] sun.security.util.DerValue是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[28,25] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/CertService.java:[16,25] sun.security.x509.X500Name是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[23,25] sun.security.pkcs.ContentInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[24,25] sun.security.pkcs.PKCS7是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[25,25] sun.security.pkcs.SignerInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[26,25] sun.security.util.DerOutputStream是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[27,25] sun.security.util.DerValue是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[28,25] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/CertService.java:[16,25] sun.security.x509.X500Name是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[23,25] sun.security.pkcs.ContentInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[24,25] sun.security.pkcs.PKCS7是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[25,25] sun.security.pkcs.SignerInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[26,25] sun.security.util.DerOutputStream是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[27,25] sun.security.util.DerValue是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[28,25] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/CertService.java:[16,25] sun.security.x509.X500Name是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[23,25] sun.security.pkcs.ContentInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[24,25] sun.security.pkcs.PKCS7是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[25,25] sun.security.pkcs.SignerInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[26,25] sun.security.util.DerOutputStream是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[27,25] sun.security.util.DerValue是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[28,25] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/CertService.java:[16,25] sun.security.x509.X500Name是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[23,25] sun.security.pkcs.ContentInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[24,25] sun.security.pkcs.PKCS7是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[25,25] sun.security.pkcs.SignerInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[26,25] sun.security.util.DerOutputStream是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[27,25] sun.security.util.DerValue是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[28,25] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/CertService.java:[16,25] sun.security.x509.X500Name是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[110,26] sun.security.x509.X500Name是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[110,66] sun.security.x509.X500Name是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[114,9] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[114,45] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[114,57] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[116,9] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[116,43] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[116,55] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[119,9] sun.security.pkcs.SignerInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[119,32] sun.security.pkcs.SignerInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[121,9] sun.security.pkcs.ContentInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[121,33] sun.security.pkcs.ContentInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[121,45] sun.security.pkcs.ContentInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[121,80] sun.security.util.DerValue是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[121,89] sun.security.util.DerValue是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[123,9] sun.security.pkcs.PKCS7是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[123,24] sun.security.pkcs.PKCS7是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[123,34] sun.security.x509.AlgorithmId是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[125,21] sun.security.pkcs.SignerInfo是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java:[127,42] sun.security.util.DerOutputStream是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/CertService.java:[152,9] sun.security.x509.X500Name是内部专用 API, 可能会在未来发行版中删除
[WARNING] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/CertService.java:[152,33] sun.security.x509.X500Name是内部专用 API, 可能会在未来发行版中删除
[INFO] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java: /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java使用了未经检查或不安全的操作。
[INFO] /Users/fxq/Public/WorkSpace/webank-demo/src/main/java/cn/isuyu/webank/demo/utils/CertUtil.java: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ webank-demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/fxq/Public/WorkSpace/webank-demo/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ webank-demo ---
[INFO] Changes detected - recompiling the module!
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ webank-demo ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ webank-demo ---
[INFO] Building jar: /Users/fxq/Public/WorkSpace/webank-demo/target/webank-demo-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.2.2.RELEASE:repackage (repackage) @ webank-demo ---
[INFO] Replacing main artifact with repackaged archive
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ webank-demo ---
[INFO] Installing /Users/fxq/Public/WorkSpace/webank-demo/target/webank-demo-1.0-SNAPSHOT.jar to /Users/fxq/.m2/repository/cn/isuyu/webank/webank-demo/1.0-SNAPSHOT/webank-demo-1.0-SNAPSHOT.jar
[INFO] Installing /Users/fxq/Public/WorkSpace/webank-demo/pom.xml to /Users/fxq/.m2/repository/cn/isuyu/webank/webank-demo/1.0-SNAPSHOT/webank-demo-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.168 s
[INFO] Finished at: 2020-01-04T14:36:43+08:00
[INFO] ------------------------------------------------------------------------

最后

以上就是爱笑石头为你收集整理的程序包sun.security.tools.keytool不存在问题解决的全部内容,希望文章能够帮你解决程序包sun.security.tools.keytool不存在问题解决所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(81)

评论列表共有 0 条评论

立即
投稿
返回
顶部