编程语言
首页 > 编程语言> > java – Maven插件何时可以访问项目类?

java – Maven插件何时可以访问项目类?

作者:互联网

我制作了一个Maven插件,用于验证和实例化项目中的类. Maven插件何时在类路径中包含项目中的类?

插件不断抛出ClassNotFoundException.

在查看Maven文档并进行搜索后询问问题.

任何帮助将不胜感激.谢谢!

解决方法:

When does a Maven plugin have on the classpath the classes in the project?

简短的回答是默认情况下没有.

看看Guide to Maven Classloading

特别:

Please note that the plugin classloader does neither contain the dependencies of the current project nor its build output. Instead, plugins can query the project’s compile, runtime and test class path from the MavenProject in combination with the mojo annotation requiresDependencyResolution from the Mojo API Specification.

如果缺少来自众所周知的工件的类,则可以将该工件添加为项目依赖项.

标签:java,maven,maven-plugin
来源: https://codeday.me/bug/20190825/1717305.html