错误:java.lang.NoClassDefFoundError:antlr / RecognitionException

时间:2016-11-06 21:45:42

标签: java hibernate maven spring-boot antlr

我有使用JPA + MySQL + Thymeleaf的Spring Boot项目,但eclipse说错误。

在marven依赖项中找到了antlr 2.7.7 jar库。

我在pom.xml中的依赖项:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

antlr是JPA和Hibernate的依赖项,但控制台说:

java.lang.ClassNotFoundException: antlr.RecognitionException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_111]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_111]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_111]
...

我制作了模型和存储库但是在调用时,findAll()函数使web应用程序崩溃。

在控制器中:

@Autowired
private CategoryRepository categoryRepository;
...
Iterable<CategoryModel> categories = categoryRepository.findAll();

在存储库中:

public interface CategoryRepository extends CrudRepository<CategoryModel, BigInteger>{

    List<CategoryModel> findById(BigInteger id);
}

会发生什么?

1 个答案:

答案 0 :(得分:2)

我的解决方案:本地存储库已损坏,从Linux删除文件夹〜/ .m2 /并重新加载eclipse。