[英]Maven Clean Install build fails: Spring Boot- MVC, JPA
I'm currently attempting to build a war from my Spring boot project. 我目前正在尝试从我的Spring启动项目中发动战争。 My project is mainly an MVC application that uses JPA to persist to DB2(It was a project requirement). 我的项目主要是一个使用JPA持久化到DB2的MVC应用程序(这是一个项目需求)。
For persistence, I'm using repo interfaces extended from Spring's CRUDRepository class. 为了持久性,我使用从Spring的CRUDRepository类扩展的repo接口。
I'm using Eclipse for development, and the build is fine: I'm able to get my project up and running with Eclipse, test with localhost. 我正在使用Eclipse进行开发,并且构建很好:我能够使用Eclipse启动并运行我的项目,并使用localhost进行测试。 Everything is being autowired and set up correctly. 一切都已自动接线并正确设置。 However, I'm attempting to build with maven clean install to generate a war. 但是,我正在尝试使用maven全新安装进行构建以产生战争。
I think the problem is mainly with the autowiring of the JPA repos. 我认为问题主要出在JPA回购协议的自动装配上。
Am I going about this the right way? 我要这样做正确吗? Should I be building with maven in the first place? 我应该首先使用Maven进行构建吗? Should I contemplate my future? 我应该考虑我的未来吗?
Okay, here is my files: 好的,这是我的文件:
POM.xml 的pom.xml
https://www.dropbox.com/s/e1lb4qz1agtcac5/pom.xml?dl=0 https://www.dropbox.com/s/e1lb4qz1agtcac5/pom.xml?dl=0
Application.properties: 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*
The Maven clean install console output : Maven全新安装控制台输出 :
[...]
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
Sorry, but the console file is quite large and I didn't want an epic saga of a question here. 抱歉,控制台文件很大,我不想在这里出现一个史诗般的传奇故事。
You are missing DB2 driver dependency in your project, you can see it in your log: 您的项目中缺少DB2驱动程序依赖性,您可以在日志中看到它:
Caused by: java.lang.IllegalStateException: Cannot load driver class: com.ibm.db2.jcc.DB2Driver
You need to get the jar somewhere (most likely IBM website ..., I doubt it is in the maven central), then install it locally into your repository and add to your pom. 您需要将jar放在某个地方(很可能是IBM网站...,我怀疑它在maven中央),然后将其本地安装到存储库中并添加到pom中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.