当我尝试配置我的会话工厂时,我收到此错误,根据google的结果将javaee-api放在提供的范围内应解决问题,但它不会:/ 在您的特殊情况下,看起来javax.validation接口库在测试中是不可用的。可能他们没有在javaee-api中包含。如果是这种情况,请添加:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<scope>test</scope>
</dependency>
full pom.xml [code]
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>tele.crm</groupId>
<artifactId>crm-service-utils</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>tele.crm</groupId>
<artifactId>crm-billing-client</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.36</version>
</dependency>
</dependencies>
java Code:
public static void main( String[] args )
{
show();
}
public static void show()
{
Session session = null;
Transaction transaction = null;
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
try
{
System.out.println("aaa"+sessionFactory);
session = sessionFactory.openSession();
System.out.println(session);
transaction = session.beginTransaction();
CrmUserPojo e = new CrmUserPojo();
e.setUserId( "ASDF" );
e.setFirstName("kumar");
session.save( e );
transaction.commit();
}
catch ( Exception ss )
{
transaction.rollback();
}
finally
{
session.close();
}
System.out.println( "Sucesfully Saved" );
}
主题“main”中的异常:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.np.tele.crm.utils.HibernateUtil.<clinit>(HibernateUtil.java:29)
at com.np.test.Emp.show(Emp.java:25)
at com.np.test.Emp.main(Emp.java:15)
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:115)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
at com.np.tele.crm.utils.HibernateUtil.<clinit>(HibernateUtil.java:23)
... 2 more
答案 0 :(得分:1)
您必须提供验证API的实现:
import pandas as pd
import numpy as np
x = np.array([[ 0.00000000e+00, 0.00000000e+00, 3.71301945e-01],
[ 0.00000000e+00, 1.00000000e+00, 3.17619162e-01],
[ 0.00000000e+00, -1.00000000e+00, 3.11078923e-01],
[ 1.00000000e+00, 0.00000000e+00, 4.01434455e-01],
[ 1.00000000e+00, 1.00000000e+00, 3.16000976e-01],
[ 1.00000000e+00, -1.00000000e+00, 2.82564558e-01],
[ 2.00000000e+00, 1.00000000e+00, 3.61490457e-01],
[ 2.00000000e+00, 0.00000000e+00, 3.24832048e-01],
[ 2.00000000e+00, -1.00000000e+00, 3.13677513e-01]])
df = pd.DataFrame(x, columns=["id", "class", "p"])
df.pivot(index="id", columns="class", values="p")
您的版本可能会有所不同。
问候。
答案 1 :(得分:0)
引起:java.lang.ClassFormatError:方法中缺少Code属性......
表示您使用的jar只包含类和方法签名,但不包含方法实现。 见this