[英]Maven Clean Install build fails: Spring Boot- MVC, JPA
我目前正在尝试从我的Spring启动项目中发动战争。 我的项目主要是一个使用JPA持久化到DB2的MVC应用程序(这是一个项目需求)。
为了持久性,我使用从Spring的CRUDRepository类扩展的repo接口。
我正在使用Eclipse进行开发,并且构建很好:我能够使用Eclipse启动并运行我的项目,并使用localhost进行测试。 一切都已自动接线并正确设置。 但是,我正在尝试使用maven全新安装进行构建以产生战争。
我认为问题主要出在JPA回购协议的自动装配上。
我要这样做正确吗? 我应该首先使用Maven进行构建吗? 我应该考虑我的未来吗?
好的,这是我的文件:
的pom.xml
https://www.dropbox.com/s/e1lb4qz1agtcac5/pom.xml?dl=0
Application.properties:
spring.jpa.hibernate.naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.database-platform= DB2Platform
#spring.jpa.database-platform: DB2Platform
spring.jpa.show-sql: true
spring.jpa.generate-ddl: true
spring.datasource.driverClassName=com.ibm.db2.jcc.DB2Driver
spring.datasource.url=jdbc:db2:localhost:50000/testing
spring.datasource.username=*A username*
spring.datasource.password=*a password*
[...]
2016-02-04 12:07:41.943 WARN 14116 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.ibm.db2.jcc.DB2Driver
[...]
Results :
Tests in error:
APIApplicationTests.contextLoads » IllegalState Failed to load ApplicationC...
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.334 s
[INFO] Finished at: 2016-02-04T12:07:42+00:00
[INFO] Final Memory: 28M/226M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project API: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\AdamM\git\api-monitor\API\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
抱歉,控制台文件很大,我不想在这里出现一个史诗般的传奇故事。
您的项目中缺少DB2驱动程序依赖性,您可以在日志中看到它:
Caused by: java.lang.IllegalStateException: Cannot load driver class: com.ibm.db2.jcc.DB2Driver
您需要将jar放在某个地方(很可能是IBM网站...,我怀疑它在maven中央),然后将其本地安装到存储库中并添加到pom中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.