我有一个Spring Boot应用程序,如果我使用提供的jar文件,它可以正常工作。但是当我尝试将它作为war文件部署到Tomcat 8时,它无法工作。我得到以下输出:
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.ServerProperties org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration.server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties': Could not bind properties to [unknown] (target=server, ignoreInvalidF
ields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is javax.validation.ValidationException: HV000041: Call to TraversableResolver.isReachable() threw an exception.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:133)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:124)
at org.springframework.boot.context.web.SpringB
ootServletInitializer.onStartup(SpringBootServletInitializer.java:81)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5170)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1293)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:673)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:221)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
at org
.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:
614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2503)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2492)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunn
able.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.ServerProperties org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration.server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties': Could not bind properties to [unknown] (target=server, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is javax.validation.ValidationException: HV000041: Call to TraversableResolver.isReachable() threw an exception.
at org.spring
framework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springfra
mework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java
:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.boot.context.embedded.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:209)
at org.springframework.boot.context.embedded.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:85)
at org.springframework.boot.context.embedded.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:73)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getServletContextInitializerBeans(EmbeddedWebApplicationContext.java:234)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:221)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:84)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(Emb
eddedWebApplicationContext.java:206)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 42 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.ServerProperties org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration.server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties': Could not bind properties to [unknown] (target=server, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is javax.validation.ValidationException: HV000041: Call to TraversableResolver.isReachable() threw an exception.
at org.
springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 67 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties': Could not bind properties to [unknown] (target=server, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is javax.validation.ValidationException: HV000041: Call to TraversableResolver.isReachable() threw an exception.
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:304)
at org.spring
framework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:251)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factor
y.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1120)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1044)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
... 69 common frames omitted
Caused by: javax.validation.ValidationException: HV000041: Call to TraversableResolver.isReachable() threw an exception.
at org.hibernate.validator.internal.engine.ValidatorImpl.isReachable(ValidatorImpl.java:1405)
at org.hibernate.validator.internal.engine.Vali
datorImpl.isValidationRequired(ValidatorImpl.java:1381)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:542)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:487)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:451)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:403)
at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:206)
at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:92)
at org.springframework.validation.DataBinder.validate(DataBinder.java:768)
at org.springframework.boot.bind.PropertiesConfigurationFactory.validate(PropertiesConfigurationFactory.java:286)
at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:255)
at o
rg.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:227)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:297)
... 82 common frames omitted
Caused by: java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider
at javax.persistence.Persistence$1.isLoaded(Persistence.java:110)
at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:56)
at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:137)
at org.hibernate.validator.internal.engine.resolver.CachingTraversableResolverForSingleValidation.isReachable(CachingTraversableResolverForSingleValidation.java:46)
at org.hibernate.validator.internal.engine.ValidatorImpl.is
Reachable(ValidatorImpl.java:1396)
... 94 common frames omitted
2015-10-17 21:32:00.194 INFO 14049 --- [apr-8080-exec-4] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/classes/, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/validation-api-1.1.0.Final.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/dom4j-1.6.1.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/jboss-logging-3.1.3.GA.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/hibernate-core-4.3.8.Final.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/bootstrap-3.2.0.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/tomcat-jdbc-8.0.20.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-beans-4.1.7.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/angularjs-1.3.8.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-context-4.1.7.RELEASE.jar, file:/var/
lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-web-4.1.7.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/snakeyaml-1.14.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-aspects-4.1.6.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-data-jpa-1.7.2.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/mysql-connector-java-5.1.13.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/aspectjweaver-1.8.5.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/angular-bootstrap-0.13.4.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/angular-route-1.4.7.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/aspectjrt-1.8.5.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-boot-starter-jdbc-1.2.3.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/antlr-2.7.7.jar, file:/var/lib/tomcat8/webapps/Invento
ryAccounting/WEB-INF/lib/spring-orm-4.1.6.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-tx-4.1.6.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/jboss-logging-annotations-1.2.0.Beta1.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/jcl-over-slf4j-1.7.12.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-core-4.1.7.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-boot-actuator-1.2.6.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-boot-starter-web-1.2.6.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/tomcat-juli-8.0.20.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/classmate-1.0.0.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/jandex-1.1.0.Final.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-boot-starter-logging-1.2.6.RELEASE.jar, file:/var/lib/tomca
t8/webapps/InventoryAccounting/WEB-INF/lib/aopalliance-1.0.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/javassist-3.18.1-GA.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/jackson-databind-2.4.6.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/hibernate-commons-annotations-4.0.5.Final.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/jul-to-slf4j-1.7.12.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/hibernate-validator-5.1.3.Final.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-aop-4.1.7.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-boot-1.2.6.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-boot-starter-aop-1.2.3.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-webmvc-4.1.7.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/logback-core-1.1.3.jar, file:/var/lib/to
mcat8/webapps/InventoryAccounting/WEB-INF/lib/org.json-chargebee-1.0.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/jackson-core-2.4.6.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/slf4j-api-1.7.12.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/jquery-1.11.1.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/javax.transaction-api-1.2.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/log4j-over-slf4j-1.7.12.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/jackson-annotations-2.4.0.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/xml-apis-1.0.b2.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-boot-autoconfigure-1.2.6.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/hibernate-entitymanager-4.3.8.Final.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-data-commons-1.9.2.RELEASE.jar, file:/var/lib/tomcat8/webap
ps/InventoryAccounting/WEB-INF/lib/spring-jdbc-4.1.6.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-boot-starter-data-jpa-1.2.3.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-boot-starter-actuator-1.2.6.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-boot-starter-1.2.6.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/hibernate-jpa-2.1-api-1.0.0.Final.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/spring-expression-4.1.7.RELEASE.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/logback-classic-1.1.3.jar, file:/var/lib/tomcat8/webapps/InventoryAccounting/WEB-INF/lib/angular-1.4.7.jar]
2015-10-17 21:32:00.196 ERROR 14049 --- [apr-8080-exec-4] o.s.boot.SpringApplication : Application startup failed
我的设置是在Arch Linux上与MariaDB (MySQL),我使用gradle作为构建工具。这是我的构建文件:
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
classpath("gradle.plugin.com.craigburke.gradle:jasmine-gradle:1.2.0")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'com.craigburke.jasmine'
jasmine {
basePath = '/'
files = [
'https://raw.githubusercontent.com/angular/code.angularjs.org/master/1.3.8/angular.min.js',
'https://raw.githubusercontent.com/angular/code.angularjs.org/master/1.3.8/angular-route.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.14.0/ui-bootstrap-tpls.min.js',
'https://raw.githubusercontent.com/angular/code.angularjs.org/master/1.3.8/angular-mocks.js',
'src/main/resources/static/js/*',
'src/main/resources/static/js/controllers/*',
'src/test/resources/static/js/*.spec.js',
]
additional = [
colors: true
]
}
jar {
baseName = 'InventoryAccounting'
}
war {
baseName = 'InventoryAccounting'
}
configurations {
providedRuntime
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java {
srcDir 'src/java'
}
resources {
srcDir 'src/resources'
srcDir 'src/generated-resources'
}
}
}
springBoot {
mainClass = "app.Application"
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
// tag::actuator[]
compile("org.springframework.boot:spring-boot-starter-actuator")
// end::actuator[]
compile("org.springframework.boot:spring-boot-starter-data-jpa:1.2.3.RELEASE")
compile("mysql:mysql-connector-java:5.1.13")
compile("org.webjars:angularjs:1.3.8")
compile("org.webjars.npm:angular-route:1.4.7")
compile("org.webjars.bower:angular-bootstrap:0.13.4")
compile("org.webjars:bootstrap:3.2.0")
compile("org.json:org.json:chargebee-1.0")
testCompile("org.webjars:jasmine:2.0.0")
testCompile("org.hamcrest:hamcrest-all:1.3")
testCompile("org.springframework.boot:spring-boot-starter-test")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.7'
}
我的应用程序类是这样的:
package app;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.boot.builder.SpringApplicationBuilder;
@SpringBootApplication
@RestController
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
对我来说,这是日志中最重要的事情:
java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider
但我不知道是什么原因造成的。我似乎不明白我错过了什么。想法吗?
经过一些修补,我修复了这个问题。它发生在我在gradle构建文件中添加了以下依赖项之后:
dependencies {
...
compile("org.eclipse.persistence:javax.persistence:2.1.0")
...
}
我根据我所拥有的日志计算出了它。