gpt4 book ai didi

java.lang.NoClassDefFoundError : javax/validation/ParameterNameProvider

转载 作者:IT老高 更新时间:2023-10-28 21:10:00 24 4
gpt4 key购买 nike

我编写了一个小型 hibernate 应用程序并得到以下堆栈跟踪:

org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:154)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:312)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)
at com.beingjavaguys.hbn.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
at com.beingjavaguys.hbn.HibernateUtil.<clinit>(HibernateUtil.java:10)
at crud.UserDao.addUser(UserDao.java:12)
at com.beingjavaguys.hbn.App.main(App.java:53)
Caused by: java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider
...

我不明白这个错误的原因。

代码:

       Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
configuration.getProperties()).build();
return configuration.buildSessionFactory(serviceRegistry); // exception thrown here

我的 pom.xml:

...
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.5.Final</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<scope>provided</scope>
</dependency>
...
...

我已阅读相关主题,但我真的不明白如何修复它 - 我不想推出到 hibernate 4.0 版本。

如何解决?

最佳答案

只需删除 javax.validation 依赖项

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>

这解决了我的这个特殊问题。

关于java.lang.NoClassDefFoundError : javax/validation/ParameterNameProvider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24652753/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com