【问题标题】:Maven install errorMaven安装错误
【发布时间】:2017-06-23 08:49:58
【问题描述】:
Running me.kafeitu.demo.activiti.service.oa.leave.LeaveWorkflowServiceTest
2017-06-23 15:49:58,230  INFO [main] support.PropertySourcesPlaceholderConfigurer.loadProperties:181 | Could not load properties from class path resource [application.test.local.properties]: class path resource [application.test.local.properties] cannot be opened because it does not exist
2017-06-23 15:49:58,464  WARN [main] support.GenericApplicationContext.refresh:487 | Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'entityManagerFactory' defined in class path resource [applicationContext-test.xml]: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"
    at  ... 43 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'entityManagerFactory' defined in class path resource [applicationContext-test.xml]: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"
    ... 31 more
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"
    at ... 43 more
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.231 sec <<< FAILURE!
testAllPass(me.kafeitu.demo.activiti.service.oa.leave.LeaveWorkflowServiceTest)  Time elapsed: 0.001 sec  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:94)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'entityManagerFactory' defined in class path resource [applicationContext-test.xml]: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"
    ... 31 more
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"
    at  ... 43 more

Running me.kafeitu.demo.activiti.web.user.UserControllerTest
2017-06-23 15:49:58,470  INFO [main] support.DefaultTestContextBootstrapper.getTestExecutionListeners:182 | Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@3129f63e, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@39e579a9, org.springframework.test.context.support.DirtiesContextTestExecutionListener@89663f1, org.springframework.test.context.transaction.TransactionalTestExecutionListener@497b679e, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@44cfdbc2]
2017-06-23 15:49:58,473  INFO [main] xml.XmlBeanDefinitionReader.loadBeanDefinitions:317 | Loading XML bean definitions from class path resource [applicationContext-test.xml]
2017-06-23 15:49:58,629  INFO [main] support.GenericApplicationContext.prepareRefresh:510 | Refreshing org.springframework.context.support.GenericApplicationContext@2a64c0d9: startup date [Fri Jun 23 15:49:58 CST 2017]; root of context hierarchy
2017-06-23 15:49:58,655  INFO [main] support.PropertySourcesPlaceholderConfigurer.loadProperties:172 | Loading properties file from class path resource [application.properties]
2017-06-23 15:49:58,655  INFO [main] support.PropertySourcesPlaceholderConfigurer.loadProperties:172 | Loading properties file from class path resource [application.test.properties]
2017-06-23 15:49:58,655  INFO [main] support.PropertySourcesPlaceholderConfigurer.loadProperties:172 | Loading properties file from class path resource [application.test.local.properties]
2017-06-23 15:49:58,656  WARN [main] support.PropertySourcesPlaceholderConfigurer.loadProperties:181 | Could not load properties from class path resource [application.test.local.properties]: class path resource [application.test.local.properties] cannot be opened because it does not exist
2017-06-23 15:49:58,657  WARN [main] support.GenericApplicationContext.refresh:487 | Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'entityManagerFactory' defined in class path resource [applicationContext-test.xml]: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"
    at Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"
    at  ... 43 more
2017-06-23 15:49:58,658 ERROR [main] context.TestContextManager.prepareTestInstance:215 | Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@39e579a9] to prepare test instance [me.kafeitu.demo.activiti.web.user.UserControllerTest@95e60cf]
java.lang.IllegalStateException: Failed to load ApplicationContext
    at  ... 31 more
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"
    at  ... 43 more

Results :

Failed tests:   testWithWebservice(me.kafeitu.demo.activiti.service.oa.leave.LeaveWebserviceInWorkflowTest): expected:<1> but was:<0>
  testWithWebserviceFalse(me.kafeitu.demo.activiti.service.oa.leave.LeaveWebserviceInWorkflowTest): expected:<1> but was:<0>

Tests in error: 
  testUserData(me.kafeitu.demo.activiti.dao.InitDataTest): Failed to load ApplicationContext
  allClassMapping(me.kafeitu.demo.activiti.dao.JpaMappingTest): Failed to load ApplicationContext
  crudEntity(me.kafeitu.demo.activiti.dao.LeaveDaoTest): Failed to load ApplicationContext
  testProcessEngines(me.kafeitu.demo.activiti.engine.ProcessEngineTest): Failed to load ApplicationContext
  testSave(me.kafeitu.demo.activiti.service.oa.leave.LeaveManagerTest): Failed to load ApplicationContext
  testWithWebservice(me.kafeitu.demo.activiti.service.oa.leave.LeaveWebserviceInWorkflowTest): Error parsing XML
  testWithWebserviceFalse(me.kafeitu.demo.activiti.service.oa.leave.LeaveWebserviceInWorkflowTest): resource 'diagrams/leave-webservice.bpmn' not found
  testAllPass(me.kafeitu.demo.activiti.service.oa.leave.LeaveWorkflowServiceTest): Failed to load ApplicationContext
  testUserExistInDb(me.kafeitu.demo.activiti.web.user.UserControllerTest): Failed to load ApplicationContext
  testUserNotExistInDb(me.kafeitu.demo.activiti.web.user.UserControllerTest): Failed to load ApplicationContext

Tests run: 12, Failures: 2, Errors: 10, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.160 s
[INFO] Finished at: 2017-06-23T15:49:58+08:00
[INFO] Final Memory: 39M/357M
[INFO] ------------------------------------------------------------------------

enter image description here

其中有一些错误,我导入maven项目,设置jdk版本和动态web模块版本等,当我maven clean和下一步安装时,maven返回错误信息,根据提示,我看到了所有错误都指向休眠方言,并且无法解析字符串值$(hibernate.dialect)中的“休眠方言”。然后我找到了XML文件“application-test.xml”并检查出了什么问题!但我不知道设置成这样是不行的原因!谁能告诉我设置问题的原因或解决方法。谢谢!

【问题讨论】:

  • 将带有休眠方言信息的 application.test.local.properties 文件放在资源文件夹中。错误说属性文件不可用,因此无法解析休眠属性。
  • 首先请阅读如何提问。并提供Minimal Complete Verifiable Example

标签: java spring hibernate maven


【解决方案1】:

您需要将 hibernate 属性添加到 application.properties 文件和/或 test-application.properties 文件。至少 hibernate.dialect 不见了。在 google (StackOverflow) 中搜索您正在使用的数据库的正确方言。

【讨论】:

    猜你喜欢
    • 2015-10-21
    • 2017-06-20
    • 1970-01-01
    • 2017-12-24
    • 2013-09-26
    • 2014-09-19
    • 2014-10-05
    • 2014-06-29
    • 2015-12-18
    相关资源
    最近更新 更多