[英]Cannot run javadoc from console at java 10
I'm trying to get javadocs for my classes directly from console with following code javadoc -sourcepath./src/main java.packageName
.我正在尝试使用以下代码直接从控制台获取我的类的 javadocs
javadoc -sourcepath./src/main java.packageName
。 Those classes have dependencies on external libraries (eg junit.framework
).这些类依赖于外部库(例如
junit.framework
)。 This code is easy to compile from IntelliJ IDEA or via mvn clean install
, but when I'm trying to create javadocs I face the problem that external classes and packages cannot be recognized (eg error: package junit.framework does not exist
).此代码很容易从 IntelliJ IDEA 或通过
mvn clean install
编译,但是当我尝试创建 javadocs 时,我面临无法识别外部类和包的问题(例如error: package junit.framework does not exist
)。 Same problem occurs with JDK 8 as well, but there those are warnings and javadocs are generated anyway. JDK 8 也会出现同样的问题,但是还是会产生警告和 javadocs。
There are two approaches you could take to get the javadocs to build from the command line:您可以采用两种方法从命令行构建 javadocs:
Add the maven-javadoc-plugin to your project's POM file so that you can use (for example) mvn javadoc:javadoc
to generate the javadocs.将 maven-javadoc-plugin 添加到项目的 POM 文件中,以便您可以使用(例如)
mvn javadoc:javadoc
来生成 javadocs。 See the plugin documentation for more details.有关更多详细信息,请参阅插件文档。
Run javadoc
directly with the correct command-line arguments.使用正确的命令行 arguments 直接运行
javadoc
。
I suspect that there are a couple of reasons why your current attempt is failing:我怀疑您当前的尝试失败有几个原因:
You appear to be generating javadocs for your src/test
tree.您似乎正在为您的
src/test
树生成 javadocs。 That may be unintentional.这可能是无意的。
(If the above "error: ..." is coming from the src/main
javadoc generation, I'm puzzled why your src/main
source code is referring to the junit.framework
package. It could do, but production code wouldn't normally depend on a test framework.) (如果上面的“错误:...”来自
src/main
javadoc 生成,我很困惑为什么您的src/main
源代码指的是junit.framework
package。它可以做到,但生产代码不会t 通常取决于测试框架。)
You need to use a -classpath
option to tell javadoc
where to find the external libraries are.您需要使用
-classpath
选项来告诉javadoc
在哪里可以找到外部库。
"This code is easy to compile from intellij" just use the JavaDoc function from intellij. “这段代码很容易从 intellij 编译”,只需使用 intellij 的 JavaDoc function。 It should work
它应该工作
Tools - Generate JavaDoc工具 - 生成 JavaDoc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.