我已經實現了Checkstyle Listener。它的工作之前,(我想用5.0測試版),但現在(5.0),CheckStyle的失敗與以下調用堆棧Checkstyle爲什麼會嘗試爲我的聽衆創建檢查
Unable to create Checker: cannot initialize module de.xyz.toxicity.TeamcityListener - Unable to instantiate de.xyz.toxicity.TeamcityListener
com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module de.xyz.toxicity.TeamcityListener - Unable to instantiate de.xyz.toxicity.TeamcityListener
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:177)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:207)
at com.puppycrawl.tools.checkstyle.Main.createChecker(Main.java:138)
at com.puppycrawl.tools.checkstyle.Main.main(Main.java:115)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate de.xyz.toxicity.TeamcityListener
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:156)
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:152)
... 3 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to instantiate de.xyz.toxicity.TeamcityListenerCheck
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.doMakeObject(PackageObjectFactory.java:99)
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(PackageObjectFactory.java:153)
... 4 more
我的配置文件看起來像這樣
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<property name="severity" value="warning"/>
<module name="de.xyz.toxicity.TeamcityListener" />
<module name="FileLength">
<property name="max" value="500"/>
</module>
<module name="TreeWalker">
<module name="FileContentsHolder"/>
<module name="AnonInnerLength">
<property name="max" value="35"/>
</module>
// ... more modules like this follow
</module>
</module>
一切正常當我自己的偵聽器從配置中刪除。
讓我困惑的是:爲什麼checkstyle在尋找TeamcityListenerCheck類? 這樣的類不存在。我需要它嗎?它應該是什麼樣子?
我de.xyz.toxicity.TeamcityListener是不是在類路徑中。 – 2012-03-14 09:36:05
謝謝!那正是我的問題。 ANT類路徑不喜歡我的jar或類的相對路徑。我將這些課程放在完整的路徑中,並且工作正常。我可以忍受這一點。 – bono 2012-03-15 15:59:37