Java Hibernate无法从https域连接
在我的本地服务器上,我可以对我的服务器进行api调用,我可以看到这些值被保存到数据库中。 但是,当上线并使用实际的域地址时,我得到以下错误:Java Hibernate无法从https域连接,java,hibernate,amazon-elastic-beanstalk,Java,Hibernate,Amazon Elastic Beanstalk,在我的本地服务器上,我可以对我的服务器进行api调用,我可以看到这些值被保存到数据库中。 但是,当上线并使用实际的域地址时,我得到以下错误: java.lang.NoClassDefFoundError: Could not initialize class d.d.util.HibernateUtil 我的HibernateUtil.java是: import org.hibernate.SessionFactory; import org.hibernate.cfg.Configurati
java.lang.NoClassDefFoundError: Could not initialize class d.d.util.HibernateUtil
我的HibernateUtil.java是:
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static final SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
return new Configuration().configure().buildSessionFactory();
}
catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static void shutdown() {
// Close caches and connection pools
getSessionFactory().close();
}
}
来自亚马逊的日志向我展示了其他一些东西:
Exception occurred during processing request: uid is required
java.lang.Exception: uid is required
at d.d.Pamper.action.GetUserProfileAction.execute(GetUserProfileAction.java:16) ~[classes/:?]
这是我自己的异常,如果UID为null,我将抛出该异常。
NoClassDefFoundError
表示HibernateUtil
缺少某个依赖类。看起来,您的实时系统缺少了org.hibernate.
类。我使用的是亚马逊的数据库,它需要一些配置才能从互联网上访问。那么我如何上传依赖项呢?有很多选择。例如,用maven将它们打包到单个jar中。我通常使用SpringBootMaven插件。您有什么样的应用程序,以及如何部署它?这是一个struts2应用程序,我正在使用eclipse将其导出为war文件,然后将其上载到Amazon的elastic beanstalk。尝试使用maven war插件:这是一个简单的示例谢谢,我尝试过这样做,但仍然遇到相同的错误