spring-boot安全性注释@Configuration的SecurityConfig会出现此错误



我遵循了这个链接spring安全教程http://spring.io/guides/gs/securing-web/

我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>org.springframework</groupId>
<artifactId>gs-securing-web</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<start-class>demo.Application</start-class>
</properties>
<build>
<plugins>
<plugin> 
<artifactId>maven-compiler-plugin</artifactId> 
<version>2.3.2</version> 
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>

运行我的应用程序时,我得到了这个错误:

java.util.concurrent.ExecutionException:org.apache.catalina.LifecycleException:无法启动组件[StandardEngine[Tomcat].StandardHost[localhost].StandardsContext[]位于java.util.concurrent.FFutureTask.report(FutureTask.java:122)位于java.util.concurrent.FFutureTask.get(FutureTask.java:188)网址:org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)网址:org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:799)网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)网址:org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)网址:org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)位于java.util.concurrent.FFutureTask.run(FutureTask.java:262)位于java.util.concurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1145)位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)在java.lang.Thread.run(线程.java:744)由:org.apache.catalina.LifecycleException引起:无法启动组件[StandardEngine[Tomcat].StandardHost[localhost].StandardsContext[]网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)…省略了6个常用框架由:org.springframework.beans.factory.BeanCreationException:创建类路径资源[org/springframework/security/config/annotation/web/config/WebSecurityConfiguration.class]中定义的名称为"springSecurityFilterChain"的bean时出错:bean实例化失败;嵌套异常为org.springframework.beans.factory.BeanDefinitionStoreException:factory方法[public javax.servlet.Filter org.springfframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain()throws java.lang.exception]抛出异常;嵌套异常为java.lang.IollegalStateException:org.springframework.security.config.annotation.ObjectPostProcessor是必需的bean。确保您已使用@EnableWebSecurity和@Configuration位于org.springframework.beans.factory.support.ConstrutorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:597)网址:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094)网址:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989)网址:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)网址:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)网址:org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)位于org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)网址:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)网址:org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)网址:org.springframework.boot.context.EmbeddedWebApplicationContext.getOrderedBeansOfType(EmbeddedWebApplicationContext.java:367)位于org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getServletContextInitializerBeans(EmbeddedWebApplicationContext.java:268)网址:org.springframework.boot.context.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:213)位于org.springframework.boot.context.embedded.tomcat.ServletContextInitializerLifecycleListener.lifecycleEvent(ServletContextInitializedrLifecycleListener.java:54)网址:org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)网址:org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)网址:org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5535)网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)…省略了6个常用框架由:org.springframework.beans.factory.BeanDefinitionStoreException引起:factory方法[public javax.servlet.Filter org.springfframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain()throws java.lang.Exception]抛出异常;嵌套异常为java.lang.IollegalStateException:org.springframework.security.config.annotation.ObjectPostProcessor是必需的bean。确保您已使用@EnableWebSecurity和@Configuration网址:org.springframework.beans.factory.support.SimpleInstantiationStrategy.instante(SimpleInstantiationStrategy.java:188)位于org.springframework.beans.factory.support.ConstrutorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586)…省略了22个常用帧引起原因:java.lang.IollegalStateException:org.springframework.security.config.annotation.ObjectPostProcessor是必需的bean。确保您已使用@EnableWebSecurity和@Configuration位于org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter$1.postProcess(WebSecurityConfigurerAdapter.java:71)位于org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.getHttp(WebSecurityConfigurerAdapter.java:168)位于org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.init(WebSecurityConfigurerAdapter.java:276)在演示中。SecurityConfig.init(SecurityConfig.java)位于org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.init(WebSecurityConfigurerAdapter.java:61)在演示中。SecurityConfig.init(SecurityConfig.java)在演示中。SecurityConfig$$EnhancerBySpringCGLIB$$ad0def71.init()位于org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.init(AbstractConfigurationSecurityBuilder.java:369)位于org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.doBuild(AbstractConfigurationSecurityBuilder.java:322)网址:org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurity Builder.java:39)网址:org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain(WebSecurityConfiguration.java:92)网址:org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$8369fa72.CGLIB$springSecurityFilterChain$3()位于org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$8369fa72$$FastClassBySpringCGLIB$$714024ff.invoke()网址:org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)位于org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.cintercept(ConfigurationClassEnhancer.java:312)网址:org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$8369fa72.springSecurityFilterChain()在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)位于java.lang.reflect.Method.ioke(Method.java:606)位于org.springsource.load.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)网址:org.springframework.beans.factory.support.SimpleInstantiationStrategy.instante(SimpleInstantiationStrategy.java:166)…省略了23个常见帧2014-04-15 15:18:12.693错误11170---[min]org.apache.catalina.core.ContainerBase:启动过程中一个子容器出现故障java.util.concurrent.ExecutionException:org.apache.catalina.LifecycleException:无法启动组件[StandardEngine[Tomcat]。StandardHost[localhost]]位于java.util.concurrent.FFutureTask.report(FutureTask.java:122)位于java.util.concurrent.FFutureTask.get(FutureTask.java:188)网址:org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)网址:org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)网址:org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)网址:org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)网址:org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)位于org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServlet Container.initialize(TomcatEmbedded Servlet Container.java:79)位于org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServlet容器。(TomcatEmbeddedServlet容器.java:69)位于org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServlet容器工厂.getTomcatEmbedded Servlet容器(TomcatEmbedServlet容器厂.java:270)位于org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServlet ContainerFactory.getEmbeddedServletContainer(TomcatEmbedded Servlet ContainerFactory.java:145)网址:org.springframework.boot.context.EmbeddedWebApplicationContext.createEmbeddedServlet容器(EmbeddedWebApplicationContext.java:159)网址:org.springframework.boot.context.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)网址:org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)网址:org.springframework.boot.context.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)网址:org.springframework.boot.SpringApplication.refresh(SpringApplication.java:648)网址:org.springframework.boot.SpringApplication.run(SpringApplication.java:311)网址:org.springframework.boot.SpringApplication.run(SpringApplication.java:909)网址:org.springframework.boot.SpringApplication.run(SpringApplication.java:898)在演示中。Application.main(Application.java:14)导致原因:org.apache.catalina.LifecycleException:无法启动组件[StandardEngine[Tomcat].StandardHost[localhost]]网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)网址:org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)网址:org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)位于java.util.concurrent.FFutureTask.run(FutureTask.java:262)位于java.util.concurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1145)位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)在java.lang.Thread.run(线程.java:744)由:org.apache.catalina.LifecycleException引起:启动期间子容器失败网址:org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)网址:org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:799)网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)…省略了6个常用框架2014-04-15 15:18:12.708信息11170---[main].b.l.ClasspathLoggingApplicationListener:应用程序无法使用类路径启动:[文件:/home/ishac/STS/workspace/sample/target/classes/,文件:/root/.m2/repository.org/springframework/boot/spring-boot-starter-web/1.0.1.RELEASE/org/springframeter/boot/starter-web-1.0.1.RELEASE.jar,文件:/root/.m2/repositoryorg/springfframework/boot/spring-bot-starter/1.0.1.RELEASESE/org/springframework/boot/spring-boot-starter/1.0.1.RELEASE/ot-1.0.1.RELEASE.jar,文件:/root/.m2/repository.org/springframework/boot/spring-boot autoconfig/1.0.1.RELEASE/spring-boot-autoconfigure-1.0.1.RELEASE.jar、文件:/rot/.m2/depository.org/spring framework/boot/spring-boot-starter-logging/1.0.1.RELEASE/spring-boot-starter-log-1.01.RELEASE.jar,文件:/root/.m2/repository.org/slf4j/jul-to-slf4j/1.7.6/jul-to-slf4j-1.7.6.jar,文件:/rot/.m2/depository.org/slf4j/log4j-over-slf4j/1.7.6/log4j-over-slf4j-1.7.6.jar,文件:/root/.m2/repository/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar,文件:/root/.m2/repository.org/yaml/snakeyaml/1.13/snakeyaml-1.13.jar,文件:/rot/.m2/depository.org/springframework/boot/spring-boot starter tomcat/1.0.1.RELEASE/spring-boot-starter-tomcat-1.01.RELEASE.jar,文件:/root/.m2/repository.org/apache/tomcat/embed/tomcat embed el/7.0.52/tomcat-embed-el-7.0.52.jar,文件:/rot/.m2/epository.org/apache/tomcat/eembed/tomcat-embed-logging-juli/7.0.52/tomcat-eembed-logging-juli-7.0.52jar,文件:/root/.m2/repository.com/fasterxml/jackson/core/jackson annotations/2.3.0/jackson-annotations-2.3.0.jar,文件:/rot/.m2/depository.com/fasterxml/jackson/core/2.3.2/jackson-core-2.3.2.jar,文件:/root/.m2/repository.org/springframework/spring-web/4.3.RELEASE/spring-web-4.0.3.RELEASE.jar,文件:/root/.m2/repository.org/springframework/spring-webmvc/4.0.3.RELEASE.jar,文件:/rot/.m2/depository.org/spring framework/boot/spring-boot starter security/1.0.1.RELEASE/spring-boot-starter-security-1.01.RELEASE..jar,文件:/root/.m2/repository/aopalliance/aopallience-1.0.jar,文件:/root/.m2/depository.org/springframework/security/spring-security-core/3.2.3.RELEASE.jar,文件:/root/.m2/repository.org/spring framework/security-spring-security-web/3.2.3.ELEASE/spring-security-web-3.2.3.RELEASE..jar,文件:/root/.m2/repository.org/springframework/spring aop/4.0.3.RELEASE/spring-aop-4.0.3.RELEASE.jar,文件:/rot/.m2/depository.org/spring framework/spring-beans/4.0.3.RELASE.jar,文件:/root/.m2/repositoryorg/springframework/spring context/4.3.RELEASE/spring-context-4.03.RELEASE.jar,文件:/root/.m2/repository.org/springframework/spring-core/4.3.RELEASE/spring-core-4.0.3.RELEASE.jar,文件:/rot/.m2/depository.org/spring framework/spring expression/4.3.RELASE/spring-expression-4.0.3.RRELEASE.jar,文件:/root/.m2/repository.org/thymelaf/thymelaf2.1.2.RELEASE/thymelaf--2.1.2.RELEASE.jar,文件:/rot/.m2/depository/ognl/ognl/30.6/ognl-3.0.6.jar,文件为/root/.mi2/repository.org/javassist/javassist/31.8-GA/javassist-3.18.1-GA.jar,文件是/root//m2/reposition.org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6.jar,文件名为/home/isahac/STS/lib/springloaded-1.1.1.5.RELEASE。jar线程"main"org.springframework.context.ApplicationContextException出现异常:无法启动嵌入式容器;嵌套异常为org.springframework.boot.context.embedded.EmbeddedServlet异常:无法启动嵌入式Tomcat网址:org.springframework.boot.context.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135)网址:org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)网址:org.springframework.boot.context.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)网址:org.springframework.boot.SpringApplication.refresh(SpringApplication.java:648)网址:org.springframework.boot.SpringApplication.run(SpringApplication.java:311)网址:org.springframework.boot.SpringApplication.run(SpringApplication.java:909)网址:org.springframework.boot.SpringApplication.run(SpringApplication.java:898)在演示中。Application.main(Application.java:14)由以下原因引起:org.springframework.boot.context.embedded.EmbeddedServlet异常:无法启动嵌入式Tomcat位于org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServlet Container.initialize(TomcatEmbedded Servlet Container.java:106)位于org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServlet容器。(TomcatEmbeddedServlet容器.java:69)位于org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServlet容器工厂.getTomcatEmbedded Servlet容器(TomcatEmbedServlet容器厂.java:270)位于org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServlet ContainerFactory.getEmbeddedServletContainer(TomcatEmbedded Servlet ContainerFactory.java:145)网址:org.springframework.boot.context.EmbeddedWebApplicationContext.createEmbeddedServlet容器(EmbeddedWebApplicationContext.java:159)网址:org.springframework.boot.context.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)…还有7个导致原因:org.apache.catalina.LifecycleException:无法启动组件[StandardServer[-1]]网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)网址:org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)位于org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServlet Container.initialize(TomcatEmbedded Servlet Container.java:79)…还有12个导致原因:org.apache.catalina.LifecycleException:无法启动组件[StandardService[Tomcat]]网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)网址:org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)…还有14个导致原因:org.apache.catalina.LifecycleException:无法启动组件[StandardEngine[Tomcat]]网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)网址:org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)…还有16个由:org.apache.catalina.LifecycleException引起:启动期间子容器失败网址:org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)网址:org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)网址:org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)…18更多

感谢

将此依赖项添加到pom.xm

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>

最新更新