Java,IntelliJ,使用Maven(和LanguagetTool)下载依赖项

时间:2015-09-17 03:04:45

标签: java maven intellij-idea

我正在尝试让LanguageTool与Java一起工作。我安装了IntelliJ并创建了一个新的Maven项目。

在设置 - > Maven->导入我选中了“自动导入Maven项目”框。

然后我添加了LanguageTool作为项目的依赖项。我的POM文件看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>test.languagetools</groupId>
    <artifactId>LanguageToolsTest</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.languagetoo</groupId>
                <artifactId>language-en</artifactId>
                <version>3.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

</project>

我的主要课程来自LanguageTool(Link

的API页面上的示例
public class main {
    public static void main(String[] args) {
        JLanguageTool langTool = new JLanguageTool(new BritishEnglish());
//langTool.activateDefaultPatternRules();  -- only needed for LT 2.8 or earlier
        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());
        }
    }
}

但是我得到编译器无法找到类的错误。我之前从未使用过Maven,还有其他什么我应该去下载库吗?

Error:(3, 9) java: cannot find symbol
  symbol:   class JLanguageTool
  location: class main
Error:(3, 38) java: cannot find symbol
  symbol:   class JLanguageTool
  location: class main
Error:(3, 56) java: cannot find symbol
  symbol:   class BritishEnglish
  location: class main
Error:(5, 9) java: cannot find symbol
  symbol:   class List
  location: class main
Error:(5, 14) java: cannot find symbol
  symbol:   class RuleMatch
  location: class main
Error:(7, 14) java: cannot find symbol
  symbol:   class RuleMatch
  location: class main

1 个答案:

答案 0 :(得分:1)

看起来问题的一部分是依赖节中的一个简单的拼写错误:<group>org.languagetoo</group>应该是<group>org.languagetool</group>

此外,<dependencyManagement><dependency>的含义不同。我想你想要后者。