- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 java-play-spring 模板(可在此处获取: https://github.com/jamesward/play-java-spring#master ),目前我正在尝试从默认的 hibernate 数据库驱动程序切换到 mysql 驱动程序。
我已向 build.sbt 添加了一个条目:
"mysql" % "mysql-connector-java" % "5.1.12"
然后我打开application.conf并更改为
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"
至:
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost:3306/mydatabase"
重新部署我的应用程序后,出现错误:
Factory method [public javax.persistence.EntityManagerFactory configs.DataConfig.entityManagerFactory()] threw exception; nested exception is
org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
我没有更改基本配置中的任何内容,所以它保持这样:
@Configuration
@EnableTransactionManagement
public class DataConfig {
@Bean
public EntityManagerFactory entityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setShowSql(true);
vendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
entityManagerFactory.setPackagesToScan("models");
entityManagerFactory.setJpaVendorAdapter(vendorAdapter);
entityManagerFactory.setDataSource(dataSource());
entityManagerFactory.setJpaPropertyMap(new HashMap<String, String>(){{
put("hibernate.hbm2ddl.auto", "create-drop");
}});
entityManagerFactory.afterPropertiesSet();
return entityManagerFactory.getObject();
}
@Bean
public PlatformTransactionManager transactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager(entityManagerFactory());
return transactionManager;
}
@Bean
public DataSource dataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(Play.application().configuration().getString("db.default.driver"));
dataSource.setUrl(Play.application().configuration().getString("db.default.url"));
return dataSource;
}
}
有谁知道这个错误的原因是什么?下面是完整的错误堆栈:
play.api.UnexpectedException: Unexpected exception[BeanCreationException: Error creating bean with name 'application': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private services.BarService controllers.Application.barService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'barServiceImpl': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class configs.DataConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.persistence.EntityManagerFactory configs.DataConfig.entityManagerFactory()] threw exception; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:166) ~[play_2.10-2.3.7.jar:2.3.7]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:130) ~[play_2.10-2.3.7.jar:2.3.7]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:130) ~[play_2.10-2.3.7.jar:2.3.7]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:128) ~[play_2.10-2.3.7.jar:2.3.7]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'application': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private services.BarService controllers.Application.barService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'barServiceImpl': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class configs.DataConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.persistence.EntityManagerFactory configs.DataConfig.entityManagerFactory()] threw exception; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private services.BarService controllers.Application.barService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'barServiceImpl': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class configs.DataConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.persistence.EntityManagerFactory configs.DataConfig.entityManagerFactory()] threw exception; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:555) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'barServiceImpl': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class configs.DataConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.persistence.EntityManagerFactory configs.DataConfig.entityManagerFactory()] threw exception; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:356) ~[spring-orm-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class configs.DataConfig: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.persistence.EntityManagerFactory configs.DataConfig.entityManagerFactory()] threw exception; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:601) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1113) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1008) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:505) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.persistence.EntityManagerFactory configs.DataConfig.entityManagerFactory()] threw exception; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:188) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver$3.run(ConstructorResolver.java:584) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_31]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1113) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:104) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:71) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:205) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
最佳答案
我自己解决了,我只是修改了 dataSource 配置,如下所示:
@Bean
public DataSource dataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(Play.application().configuration().getString("db.default.driver"));
dataSource.setUrl(Play.application().configuration().getString("db.default.url"));
dataSource.setUsername(Play.application().configuration().getString("db.default.user"));
dataSource.setPassword(Play.application().configuration().getString("db.default.password"));
return dataSource;
}
毕竟没那么难,留给 future 的 Play 新手吧。
关于java - 当 'hibernate.dialect' 未设置时,DialectResolutionInfo 不能为 null - PlayFramework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28679424/
我正在使用Play 2.1.0,突然之间一切都很好,当我从Play控制台执行~run时遇到了这个奇怪的错误(附加快照)。 环境: Windows 7,IntelliJ12,Mysql,JDK 1.6
最佳答案在评论部分(所以我不能给他们答案:()。 我想知道 playframework 是否以这种方式异步(这将是真正的异步或完全异步)。是的, Play 在前端是异步的,允许 100 个线程上的 1
以编程方式停止 Play 应用程序以便返回到 activator 控制台的最佳方法是什么?(用Java 8玩2.3.7) 如果出现初始化问题,我的服务器应该在启动时退出。 System.exit(1)
我想用 activator run在不发出任何请求的情况下启动应用程序。当前 activator run在启动应用程序之前等待第一个请求。有什么办法可以解决吗? 我知道 activator start
我使用带有@OnApplicationStart 的“通用”作业来做一些初始化工作。如果其中任何一个失败, Play 应该退出。我试过 Play.stop(),但在开发模式下,它会重复重启。 最佳答案
是否有一种简单/内置的方法让 Controller 检查连接是否被授权访问静态文件而不是服务器(使用数据库查找),然后在需要时提供访问权限。 有大视频文件,我想 a) 检查是否允许用户访问该文件,以及
我昨天晚上在南特(法国)和 Play! 参加了与 Guillaume Bort 的 session 。真的很棒!! 我从大约 2 周开始使用它。 Guillaume 使用了 URL http://lo
我在 Global.scala 和 application.conf application.global=Global 中添加了一些代码 object Global extends WithFilt
我正在努力让 capistrano 发布我的 PlayFramework 应用程序,但我在运行命令时遇到了一些问题。 发生的事情是 cap 运行 Play 开始命令并且它似乎正在启动,但是当我执行一个
我们正在使用 play 1.2.x 数据库进化功能。我想让脚本创建和开发正在 Play 自动测试中测试的模式 所以在测试套件之前我需要一个空的数据库。 我想过: 注册可以删除所有的@OnApplica
我在 Scala 中从事一个 playframework 项目。然而,我们的团队想要使用 scalatest 而不是规范。我已将以下内容添加到 plugins.sbt 文件中: libraryDepe
现在 playframework 有了新的版本 2,与版本 1 完全不同;后者会怎样?在 play 1 中编写的所有项目都应该绝对迁移到版本 2 吗?我想知道是否可以依靠 play 1 在近期或中期不
是否可以运行一些 Controller 和 路线仅在测试模式下? 单击链接时,我需要模拟一些响应。我将创建仅在运行 时可用的 Controller 和路由游戏测试 . 是否可以? 最佳答案 正如 Mi
我正在使用PlayFramework 2.4.6,尝试上传多部分文件(大小为18M),并且服务器返回以下错误: For request 'POST /api/myEndpoint' [Request
由于依赖于我正在使用 Play!Framework 开发 Web 应用程序的项目,我必须配置 logback 以防止它用 DEBUG 消息淹没我的输出。 但由于 log4j 是 Play!Framew
我正在使用 PlayFramework 的 2.0.2 版本,并且正在尝试创建一个游戏play.mvc.Action实现 后置过滤器 对于 http 结果。 play docs 中解释了使用 acto
我已经开发了一个基于 Play Framework 的小应用程序(我还在学习)。现在我需要把它捆绑起来运输。一种方法是创建一个 war 文件并将其部署在 servlet 容器(例如 tomcat)中
使用 Play Framework 2.1.1-RC1,我将一个项目分成多个模块,如下所示: object ApplicationBuild extends Build { val appName
我正在使用 Play 2.1 (Java) 和 Play 附带的默认 logback (1.0.7) 记录器。在我的一个 Controller 中,我使用“play.Logger”来打印调试日志消息。
这个问题不太可能帮助任何 future 的访客;它仅与一个小地理区域、一个特定时刻或一个非常狭窄的情况相关,而这些情况通常不适用于互联网的全局受众。如需帮助使这个问题更广泛地适用,visit the
我是一名优秀的程序员,十分优秀!