我试图在独立的Tomcat服务器中部署我的Spring Boot应用程序(war),但每次我都得到一个关于Logger的错误。你对这个案子有什么想法吗?
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
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.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:199)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:119)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:110)
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:69)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5156)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.jboss.logging.Slf4jLoggerProvider.getLogger(Slf4jLoggerProvider.java:29)
at org.jboss.logging.LoggerProviders.find(LoggerProviders.java:33)
at org.jboss.logging.LoggerProviders.<clinit>(LoggerProviders.java:28)
at org.jboss.logging.Logger.getLogger(Logger.java:2163)
at org.jboss.logging.Logger$1.run(Logger.java:2263)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2227)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)
at org.hibernate.validator.internal.util.logging.LoggerFactory.make(LoggerFactory.java:29)
at org.hibernate.validator.internal.util.Version.<clinit>(Version.java:27)
at org.hibernate.validator.internal.engine.ConfigurationImpl.<clinit>(ConfigurationImpl.java:66)
at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:41)
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:276)
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:223)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor$Jsr303ValidatorFactory.run(ConfigurationPropertiesBindingPostProcessor.java:381)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.afterPropertiesSet(ConfigurationPropertiesBindingPostProcessor.java:174)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
... 28 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 46 more
正如您所看到的,我使用的是tomcat 8.0.24、Spring Boot 1.2.5.Release和java.Version1.7。
我的项目非常简单(它作为一个jar工作):
1.主APP:
@SpringBootApplication
@ComponentScan
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);
}
}
2.控制器
@Controller
public class IndexController {
@RequestMapping(value = {"", "/", "/home"})
String index() {
return "index";
}
}
//index.html is in the tamplates folder.
<groupId>org.test</groupId>
<artifactId>demo</artifactId>
<version>1</version>
<packaging>war</packaging>
<name>demo</name>
<description>HelloWorld</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
<!--<start-class>demo.Application</start-class>-->
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
... etc
我知道有人删除了我上一篇文章,但我仍然认为这是一个类加载器问题。
...我用的是Spring靴和一只雄猫战争中的Spring靴...并得到相同的错误。我相信这可能是一个类加载器的问题,但还没有找到正确的解决方案。
避免使用slf4j-api将使应用程序启动,而不使用LoggerFactory NoClassDefoundError,但是hateoas类只在编译时出现,而不是在运行时出现。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
我已经在archlinux上安装了tomcat,我尝试了tomcat7和Tomcat8。根据包括官方文档在内的多个来源,部署WAR文件就像将其放入webapps文件夹(在我的示例中是/var/lib/tomcat7/webapps)一样容易。WAR文件被分解。但我不知道如何访问我的web应用程序。在localhost:8080上有一个tomcat网页。我还尝试了localhost:8080/nam
我用命令运行了一个spring boot web应用程序。但是,当将打包字段更改为war(在pom.xml中)并将其构建为war时,它未能在tomcat 7中运行。 我把我pom.xml的父母变成: 而且: 我的错误是: 我的问题是: 这里发生了什么,如何克服? 使用Spring-start真的安全吗?因为嵌入式服务器库似乎影响了它部署到j2ee容器中的可靠性。我知道,它仍然是Milestone版
5.使用cmd重新启动tomcat。 “信息:部署web应用程序目录C:\apache-tomcat-7.0.77\webapps\MyProject Jun 07,2017 4:50:19 PM org.apache.catalina.startup.hostconfig deployDirectory信息:web应用程序目录C:\apache-tomcat-7.0.77\webapps\MyP
我正在开发简单的JAX-WS WebService。我正在使用ANT构建脚本创建WAR文件。该文件在部署到Tomcat7服务器时,抛出以下异常,并出现如下部署错误。 JAXB 2.1 API是从bootstrap classloader加载的,但是这个RI(从jar:file:/d:/dreamsoln/server/apache-tomcat-7.0.29/webapps/webserviced
我在eclipse IDE中有一个ant项目。Ant build在dist文件夹中创建一个war。我将war复制到Tomcat webapps文件夹并成功部署它。现在,我将Tomcat添加到eclipse中,并尝试在这里部署war,它会忽略war文件。它没有给出任何例外bu也没有做任何有用的事情。下面是完整的Tomcat日志- 它是一个动态的Web模块项目。在Eclipse中设置Tomcat时是否
在这个问题之后,自Java EE 6以来,web.xml部署文件是可选的。我目前正在使用Java EE 7,Eclipse(kepler)和apache-tomcat-7.0.47 win x64。我在Eclipse中创建了一个动态Web项目和一个服务器项目。两个项目都有部署文件(web.xml,上下文.xml)。 在web项目中编辑web.xml并在服务器上下文中运行servlet后,当尝试访问