springboot项目添加了拦截器的注解(注册过滤器注解)(@ServletComponentScan)之后启动就报错


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.5.RELEASE)

2019-06-04 16:44:51.500  INFO 15848 --- [           main] com.hzr.demo2.Demo2Application           : Starting Demo2Application on PC-201705061124 with PID 15848 (D:\321\demo2\target\classes started by Administrator in D:\321\demo2)
2019-06-04 16:44:51.502  INFO 15848 --- [           main] com.hzr.demo2.Demo2Application           : No active profile set, falling back to default profiles: default
2019-06-04 16:44:52.117  WARN 15848 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'channelFilter' defined in null: Cannot register bean definition [Root bean: class [org.springframework.boot.web.servlet.FilterRegistrationBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'channelFilter': There is already [Generic bean: class [com.hzr.demo2.filter.ChannelFilter]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [D:\321\demo2\target\classes\com\hzr\demo2\filter\ChannelFilter.class]] bound.
2019-06-04 16:44:52.126  INFO 15848 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-04 16:44:52.128 ERROR 15848 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'channelFilter', defined in null, could not be registered. A bean with that name has already been defined in file [D:\321\demo2\target\classes\com\hzr\demo2\filter\ChannelFilter.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true


Process finished with exit code 1

黄志荣
浏览 3472回答 3
3回答

乌云下的风

希望同学能把源码贴出来,方便参考
打开App,查看更多内容
随时随地看视频慕课网APP