Tomcat 7 SEVERE:在 pom 中将 spring-data-jpa 添加到依赖项后,由于先前的错误,上下文 [] 启动失败
Posted
技术标签:
【中文标题】Tomcat 7 SEVERE:在 pom 中将 spring-data-jpa 添加到依赖项后,由于先前的错误,上下文 [] 启动失败【英文标题】:Tomcat 7 SEVERE: Context [] startup failed due to previous errors after add spring-data-jpa to dependency in pom 【发布时间】:2015-09-08 02:12:05 【问题描述】:我有一个 spring rest 应用程序。它配置了注释。
当我添加 spring-data-jpa 依赖项时,应用程序在 Tomcat 7(jdk 1.7) 上出现错误:
Jun 22, 2015 5:05:18 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/springRest-1.1.war
Jun 22, 2015 5:05:19 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/springRest-1.1] startup failed due to previous errors
我将 logging.properties 文件添加到 WEB-INF/classes:
org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler
但我没有在日志中捕获任何其他信息。
我的源代码:
MyWebApplicationInitializer.java:
import upc.ua.springrest.config.WebConfiguration;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
public class MyWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer
protected Class<?>[] getRootConfigClasses()
return null;
protected Class<?>[] getServletConfigClasses()
return new Class[]WebConfiguration.class;
protected String[] getServletMappings()
return new String[]"/";
WebConfiguration.java:
package upc.ua.springrest.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "upc.ua.springrest")
public class WebConfiguration extends WebMvcConfigurerAdapter
HelloWorldController.java:
package upc.ua.springrest.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController
@RequestMapping("/helloWorld")
public String helloWorld()
return "dataSource.toString()";
@RequestMapping("/")
public String root()
return "Hello, Alex!";
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>upc.ua</groupId>
<artifactId>springRest</artifactId>
<version>1.1</version>
<packaging>war</packaging>
<name>springRest</name>
<properties>
<endorsed.dir>$project.build.directory/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.6.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.6.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.1.6.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.1.6.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.7.2.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>$endorsed.dir</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>$endorsed.dir</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
【问题讨论】:
【参考方案1】:我在 pom 中更改了 jdk 的版本:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>$endorsed.dir</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
现在。它工作正常。
【讨论】:
出了什么问题??以上是关于Tomcat 7 SEVERE:在 pom 中将 spring-data-jpa 添加到依赖项后,由于先前的错误,上下文 [] 启动失败的主要内容,如果未能解决你的问题,请参考以下文章
tomcat-SEVERE: Error listenerStart和startup failed due
在 Tomcat 上部署应用程序会出现错误 SEVERE: Unable to process Jar entry for annotations
如何在pom.xml中配置“tomcat7-maven-plugin”?
idea启动tomcat服务失败 SEVERE [RMI TCP Connection-127.0.0.1] org.apache.catalina.core.ContainerBase.add