spring Bean已经注册- struts2-核心依赖错误

sbdsn5lh  于 5个月前  发布在  Spring
关注(0)|答案(1)|浏览(37)

我试图将一个项目迁移到Maven并声明Struts 2依赖项,但我被这个错误卡住了。我已经仔细检查了pom.xml依赖项,确保struts2-core只声明一次,添加了排除项和所有项。我还尝试了有xwork-core依赖项和无xwork-core依赖项,同样的错误。我真的卡住了,不知道如何继续。

我的错误:

15:35:29,079 INFO  [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] (ServerService Thread Pool -- 72) Parsing configuration file [struts-default.xml]
    15:35:29,124 ERROR [org.apache.struts2.dispatcher.Dispatcher] (ServerService Thread Pool -- 72) Dispatcher initialization failed: Unable to load configuration. - bean - vfs:/C:/servers/JBoss-eap-6.1/standalone/deployments/war.war/WEB-INF/lib/struts2-core-2.3.16.jar/struts-default.xml:40:72
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) [xwork-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445) [struts2-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489) [struts2-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) [struts2-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57) [struts2-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:416) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3225) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3791) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
        at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
        at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
        at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [rt.jar:1.6.0_13]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_13]
        at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_13]
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_13]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_13]
        at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_13]
        at org.jboss.threads.JBossThread.run(JBossThread.java:122)
    Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - vfs:/C:/servers/JBoss-eap-6.1/standalone/deployments/war.war/WEB-INF/lib/struts2-core-2.3.16.jar/struts-default.xml:40:72
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245) [xwork-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102) [struts2-core-2.3.16.3.jar:2.3.16.3]
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234) [xwork-core-2.3.16.3.jar:2.3.16.3]
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) [xwork-core-2.3.16.3.jar:2.3.16.3]
        ... 17 more
    Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name struts has already been loaded by bean - vfs:/C:/servers/JBoss-eap-6.1/standalone/deployments/war.war/WEB-INF/lib/struts2-core-2.3.16.3.jar/struts-default.xml:40:72 - bean - vfs:/C:/servers/JBoss-eap-6.1/standalone/deployments/war.war/WEB-INF/lib/struts2-core-2.3.16.jar/struts-default.xml:40:72
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:229) [xwork-core-2.3.16.3.jar:2.3.16.3]
        ... 20 more
    
    15:35:29,134 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/fordaq]] (ServerService Thread Pool -- 72) JBWEB000284: Exception starting filter struts: Unable to load configuration. - bean - vfs:/C:/servers/JBoss-eap-6.1/standalone/deployments/war.war/WEB-INF/lib/struts2-core-2.3.16.jar/struts-default.xml:40:72
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:501) [struts2-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) [struts2-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57) [struts2-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:416) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3225) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3791) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
        at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
        at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
        at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [rt.jar:1.6.0_13]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_13]
        at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_13]
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_13]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_13]
        at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_13]
        at org.jboss.threads.JBossThread.run(JBossThread.java:122)
    Caused by: Unable to load configuration. - bean - vfs:/C:/servers/JBoss-eap-6.1/standalone/deployments/war.war/WEB-INF/lib/struts2-core-2.3.16.jar/struts-default.xml:40:72
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) [xwork-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445) [struts2-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489) [struts2-core-2.3.16.3.jar:2.3.16.3]
        ... 15 more
    Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - vfs:/C:/servers/JBoss-eap-6.1/standalone/deployments/war.war/WEB-INF/lib/struts2-core-2.3.16.jar/struts-default.xml:40:72
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245) [xwork-core-2.3.16.3.jar:2.3.16.3]
        at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102) [struts2-core-2.3.16.3.jar:2.3.16.3]
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234) [xwork-core-2.3.16.3.jar:2.3.16.3]
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) [xwork-core-2.3.16.3.jar:2.3.16.3]
        ... 17 more
    Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name struts has already been loaded by bean - vfs:/C:/servers/JBoss-eap-6.1/standalone/deployments/war.war/WEB-INF/lib/struts2-core-2.3.16.3.jar/struts-default.xml:40:72 - bean - vfs:/C:/servers/JBoss-eap-6.1/standalone/deployments/war.war/WEB-INF/lib/struts2-core-2.3.16.jar/struts-default.xml:40:72
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:229) [xwork-core-2.3.16.3.jar:2.3.16.3]
        ... 20 more

字符串

pom.xml,依赖关系:

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-json-plugin</artifactId>
    <version>2.3.16</version>
</dependency>

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-spring-plugin</artifactId>
    <version>2.3.16</version>
</dependency>

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-struts1-plugin</artifactId>
    <version>2.3.16</version>
    <exclusions>
        <exclusion>
            <artifactId>struts2-core</artifactId>
            <groupId>org.apache.struts</groupId>
        </exclusion>
    </exclusions>
</dependency>

yzuktlbb

yzuktlbb1#

首先,你需要添加struts2-core工件并测试它是否工作,然后添加Spring和/或其他插件。请参阅如何Create Struts 2 Web Application Using Maven To Manage Artifacts and To Build The Application
核心struts2应用程序的pom.xml只需要

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

字符串
其中X.X.X.X是具体版本,即2.3.16.32.3.24.1,它将下载所有其他依赖项。与其他框架集成使用插件,不要弄乱重复的依赖项。清理,重建,重新部署。检查WEB-INF/lib,它不应该包含来自不同版本的重复库。在您的情况下,struts2-core-2.3.16.3.jarstruts2-core-2.3.16.jar都加载在classpath。这是错误,不应该有两个不同版本的相同库。
您还可以使用其他插件

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-json-plugin</artifactId>
    <version>2.3.16.3</version>
</dependency>

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-spring-plugin</artifactId>
    <version>2.3.16.3</version>
</dependency>

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-struts1-plugin</artifactId>
    <version>2.3.16.3</version>
</dependency>


可以添加到pom.xml

相关问题