から例を実行しようとすると、エラー メッセージ java.lang.NoSuchMethodError: org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar が表示されます。
http://wiki.languagetool.org/java-api
JLanguageTool langTool = new JLanguageTool(new BritishEnglish());
langTool.activateDefaultPatternRules();
List<RuleMatch> matches = langTool.check("A sentence " +
"with a error in the Hitchhiker's Guide tot he Galaxy");
for (RuleMatch match : matches) {
System.out.println("Potential error at line " +
match.getLine() + ", column " +
match.getColumn() + ": " + match.getMessage());
System.out.println("Suggested correction: " +
match.getSuggestedReplacements());
}
提供されているソリューション: java.lang.NoSuchMethodError: org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar
これは、LanguageTools の依存関係で指定された Xerces が問題を引き起こしていることを意味します。
mvn dependency:tree | grep -i xerces
結果は表示されず、Languagetools pom.xml では Xerces が明示的に除外されています。
私自身のテスト プロジェクトには、次の xerces 依存関係があります。
mvn dependency:tree | grep -i xerces
[INFO] | | | | +- org.bluestemsoftware.open.maven.tparty:xerces-impl:jar:2.9.0:compile
[INFO] | | | | \- xerces:xercesImpl:jar:2.6.2:compile
これらの依存関係の 1 つを取り除くか、依存関係の順序を変更するか、LanguageTool の正しい xerces 依存関係を追加したと思います。正しいアプローチは何でしょうか - これらの 1 つまたは他のものですか?