Maven 2 Checkstyle 配置位置
我有一个项目,它有一个 Maven 依赖项,其中包含一个 xml 文件,我在其中存储了 checkstyle 规则。 我认为只使用此配置就可以了:
<configLocation>mycheckstyle.xml</configLocation>
我的理解是应该在类路径上搜索该文件,并且我的 jar 文件是 Maven 依赖项,因此应该找到它,但是我得到了资源未找到异常。
有什么建议么?
I have a project which has as maven dependency a jar file which includes a xml file where I stored my rules for checkstyle. I thought it would be ok to just use this configuration:
<configLocation>mycheckstyle.xml</configLocation>
My understanding is that the file should be searched on the classpath and my jar file is a Maven dependency so it should be found, however I get a resource not found exception.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试将依赖项部分添加到您的插件配置中。
例如,
请参阅 Maven Checkstyle 插件 - 多模块配置 了解更多信息。
Try adding a dependencies section to your plugin configuration.
E.g.,
See Maven Checkstyle Plugin - Multimodule Configuration for more information.
正如 Checkstyle 插件页面中所述,
我从来没有在我的项目中这样做过...
您确定当 checkstyle 插件启动时包含 XML 文件的 JAR 位于类路径中吗?
As explained in the Checkstyle plugin page,
I never did that on my project...
Are you sure that the JAR containing the XML file is in the classpath when the checkstyle plugin is starting?
我有一个指定 checkstyle 插件的父级,并在其资源文件夹中包含适当的 mycheckstyle.xml。 我使用 Maven 程序集插件制作我父母资源文件夹的 jar 并将该 jar 定义为我孩子的依赖项。 因此,当子级继承 checkstyle 插件+它的配置时,它应该能够找到 mycheckstyle.xml。 我已按照 checkstyle 插件页面上的说明进行操作,但它不起作用。
I'm having a parent which specifies the checkstyle plugin and has in its resource folder the appropriate mycheckstyle.xml. I use the maven assembly plugin to make a jar of my parents resource folder and define that jar as a dependency in my child. So when the child inherits the checkstyle plugin + it's configuration from the parent it should be able to find the mycheckstyle.xml. I have followed the instructions on the checkstyle plugin page but it didn't work.
如果您有一个用于自行创建和编译检查的本地 Maven 存储库,请注意不要忘记定义
,否则
插件依赖项将仅在中央 Maven 存储库中查找,但不会找到带有检查类的本地 JAR 文件
If you have a local maven repository for your self-created and compiled checks, please be aware to not forget defining
but also
otherwise the plugin dependency will just look in central maven repo but will not find your local JAR file with your check-classes