[英]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.