xwork和xwork-core中的冲突 [英] Conflicts in xwork and xwork-core

查看:205
本文介绍了xwork和xwork-core中的冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将Struts 2与Zero Configuration,Spring,Hibernate和Maven集成。

I have been trying to integrate Struts 2 with Zero Configuration, Spring, Hibernate and Maven.

但是,我认为必须有一些我缺少的东西集成,它必须与Maven的 Pom.xml的配置相关

But, what I think there must be something which I am missing in integration and it must be related to the configuration of Maven's Pom.xml:

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

<!-- Struts 2 + Spring plugins -->
<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-spring-plugin</artifactId>
    <version>2.1.8.1</version>
</dependency>

<!-- MySQL database driver -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.9</version>
</dependency>

<!-- Spring framework --> 
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>2.5.6</version>
</dependency>

<!-- Hibernate core -->
<dependency>
    <groupId>asm</groupId>
    <artifactId>asm-all</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    <version>3.3</version>
</dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>3.6.7.Final</version>
</dependency>

<!-- Hibernate core library dependency start -->

<!-- Hibernate core library dependency end -->

<!-- Hibernate query library dependency start -->
<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-convention-plugin</artifactId>
    <version>2.1.8.1</version>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.15</version>
</dependency>

当我使用此配置时,它给我一个错误

As when I use this configuration it gives me an error

java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.finder.UrlSet.<init>(Lcom/opensymphony/xwork2/util/finder/ClassLoaderInterface;Ljava/util/Set;)V

而不是opensymphony XWork libaray我使用依赖

And instead of opensymphony XWork libaray I use dependency of

<dependency>
    <groupId>org.apache.struts.xwork</groupId>
    <artifactId>xwork-core</artifactId>
    <version>2.3.8</version>
</dependency> 

它抛出了这个异常

Caused by: Unable to load configuration. - [unknown location]
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)


推荐答案

升级Struts2的版本时,必须将应用程序所需的库更新为目标版本。 Struts2的每个发行版都提供了 lib 文件夹中与发行版本兼容的相应库集。如果您使用maven来解析和获取依赖项,您应该考虑工件 struts2-core

When you upgrade the version of Struts2, you have to update the libraries requires by your application to the target version. Each distro of Struts2 supplied with the corresponding set of libraries in the lib folder that are compatible with the version of distro. If you use maven to resolve and fetch the dependencies you should consider the artifact struts2-core.

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






它将获取此工件的所有必需依赖项,其他依赖项,例如您需要单独添加的插件。使用针对插件的相同版本。例如,要添加约定插件,请使用


It will fetch all required dependencies for this artifact, other dependencies, such as plugins you need to add separately. Use the same version targeted to plugins. For example to add a convention plugin use

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-convention-plugin</artifactId>
    <version>2.3.8</version>
</dependency>






我选择的目标版本号2.3。 8但它可能与其他功能不兼容,即Hibernate和Spring,这些版本需要通过向依赖项添加相应的工件来单独升级。


The targeted version number I've chosen 2.3.8 but it's possibly incompatible with the other features i.e. Hibernate and Spring which versions need to upgrade separately by adding corresponding artifacts to the dependencies.

最后,最耗时的是更改到项目的源代码,根据更新的DTD,API更改,修复弃用更新配置文件。为此,请考虑阅读发行说明

And finally and most time consuming is changes to the source code of the project, update the configuration files according to newer DTDs , API changes, fix deprecations. For this purpose consider reading the release notes.

另见开发maven项目的示例

这篇关于xwork和xwork-core中的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆