我有一個項目,作爲Maven依賴項的jar文件,其中包含一個xml文件,我存儲了我的checkstyle規則。我認爲只要使用這個配置就可以了: <configLocation> mycheckstyle.xml </configLocation >。我的理解是應該在類路徑上搜索文件,我的jar文件是Maven依賴項,所以應該找到它,但是我得到一個資源未找到異常。有什麼建議麼?在此先感謝..Maven 2 Checkstyle configLocation
褲褲
我有一個項目,作爲Maven依賴項的jar文件,其中包含一個xml文件,我存儲了我的checkstyle規則。我認爲只要使用這個配置就可以了: <configLocation> mycheckstyle.xml </configLocation >。我的理解是應該在類路徑上搜索文件,我的jar文件是Maven依賴項,所以應該找到它,但是我得到一個資源未找到異常。有什麼建議麼?在此先感謝..Maven 2 Checkstyle configLocation
褲褲
嘗試向您的插件配置添加依賴項部分。
例如,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.example.whizbang</groupId>
<artifactId>build-tools</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
configLocation:
指定的XML配置中使用的位置。
可能的值是文件系統路徑,URL,或類路徑資源。
我從來沒有認爲我的項目...
你肯定包含XML文件中的JAR是在類路徑時的CheckStyle插件開始?
我有一個父指定checkstyle插件,並在其資源文件夾中有相應的mycheckstyle.xml。我使用Maven Assembly插件來製作一個我父母資源文件夾的jar文件,並將該jar定義爲我孩子的依賴項。所以當孩子繼承checkstyle插件+它是父母的配置時,它應該能夠找到mycheckstyle.xml。我按照checkstyle插件頁面上的說明進行了操作,但沒有奏效。
如果你有你的自我創建和編譯檢查本地Maven倉庫,請注意不要忘記定義
<repositories>
<repository>
<id>my local repository</id>
<url>file:${basedir}/.m2artifacts</url>
</repository>
<!-- ... -->
</repositories>
而且
<pluginRepositories>
<pluginRepository>
<id>my local repository</id>
<url>file:${basedir}/.m2artifacts</url>
</pluginRepository>
<!-- ... -->
</pluginRepositories>
否則插件依賴性只會看在中央Maven回購,但不會找到您的本地JAR文件與您的檢查類
你的意思是你做了什麼解釋在這裏:http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/mu lti-module-config.html? 你可以編輯你的初始文章,並把一些pom.xml信息... – romaintaz 2009-01-29 10:17:33
沒有不完全是這樣的。這不是多模塊。這是父母對小孩的簡單繼承。父級在其報告標記中包含checkstyle插件,並且子級將其繼承。我將父資源作爲jar添加到子進程以獲得配置文件。 – kukudas 2009-01-29 10:28:33