简体   繁体   English

struts2配置bean问题

[英]struts2 configuration bean issue

Recently i started looking into struts2 and I've been noticing this weird problem 最近,我开始研究struts2,并且注意到了这个奇怪的问题

Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name struts has already been loaded by bean - jar:file:/C:/Users/M/.m2/repository/org/apache/struts/struts2-core/2.5.13/struts2-core-2.5.13.jar!/struts-default.xml:75:72

In the stack it complains about the bean already loaded with the same jar. 在堆栈中,它抱怨该bean已经装载了相同的jar。 I noticed couple questions regarding this, but nothing fixed the issue. 我注意到有几个与此有关的问题,但没有任何问题可以解决。 I am not using two struts2-core jars, both same version. 我没有使用两个相同版本的struts2核心jar。 I did mvn clean,but that didn't fix the issue. 我做了mvn clean,但这不能解决问题。

The issue is intermittent, sometimes it just works fine and sometimes it fails. 该问题是断断续续的,有时工作正常,有时失败。

pom.xml 的pom.xml

        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>2.5.13</version>
        </dependency>

Try this: 尝试这个:

  1. Close your eclipse (or other IDE); 关闭Eclipse(或其他IDE);
  2. Go to this folder on your PC C:/Users/M/.m2/repository/ and delete everything in it; 转到PC C:/Users/M/.m2/repository/上的该文件夹,然后删除其中的所有内容;
  3. Open your project and update Maven Project (Alt+F5 in eclipse). 打开您的项目并更新Maven项目(eclipse中的Alt + F5)。

This steps will restore all jars in your local repository and will fix all conflicts, if there any. 此步骤将还原本地存储库中的所有jar,并将解决所有冲突(如果存在)。

I tried clearing all the jars from .m2 folder, I also tried removing the jar from the target folders, re importing all maven dependencies. 我尝试从.m2文件夹中清除所有jar,也尝试从目标文件夹中删除jar,然后重新导入所有maven依赖项。 But that didn't work. 但这没有用。

The issue was due to intellij iml file, there was a struts2 library entry that i needed to delete 问题是由于intellij iml文件引起的,我需要删除一个struts2库条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM