gpt4 book ai didi

java - 来自不同 tomcat webapps 的冲突 spring bean

转载 作者:行者123 更新时间:2023-11-28 23:16:37 24 4
gpt4 key购买 nike

我在 Tomcat 上有两个 spring webapps。两者都是不同版本的相同应用。

当我运行 tomcat 时,它捕获错误:

SEVERE [localhost-startStop-2] org.springframework.web.context.ContextLoader.initWebApplicationContext
Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException:
Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring/spring.xml];
nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException:
Annotation-specified bean name 'userService' for bean class
[ru.ommega.service.rest.UserService] conflicts with existing, non-compatible
bean definition of same name and class [ru.ommega.service.UserService]

我的 spring.xml 有以下代码:

<context:component-scan base-package="ru.ommega.dao"/>
<context:component-scan base-package="ru.ommega.service"/>
<context:component-scan base-package="ru.ommega"/>

两个类(Class)都在不同的 war 中,怎么会发生冲突呢?

版本:

 Tomcat 8.0.14
Spring 4.3.7

抱歉英语不好

最佳答案

已解决。

我之前做了什么:

  • mvn package第一个版本
  • git checkout 需要分支
  • mvn package 第二个版本

在每个mvn package之前我需要什么

  • intellij idea 导入 maven 修改
  • intellij idea 同步(ctrl+alt+y)
  • mvn clean

关于java - 来自不同 tomcat webapps 的冲突 spring bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48584338/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com