我一直试图将Struts 2与Zero配置、Spring、Hibernate和Maven集成在一起。
但是,我认为在集成中一定有我缺少的东西,它必须与Maven的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>当我使用这个配置时,它会给我一个错误。
java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.finder.UrlSet.<init>(Lcom/opensymphony/xwork2/util/finder/ClassLoaderInterface;Ljava/util/Set;)V而不是第一交响曲XWork libaray,我使用的是
<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)发布于 2013-07-24 09:31:50
升级Struts2版本时,必须将应用程序所需的库更新到目标版本。Struts2的每个发行版都提供了与发行版兼容的lib文件夹中的相应库集。如果使用maven解析和获取依赖项,则应该考虑工件struts2-core。
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.8</version>
</dependency>它将获取此工件所需的所有依赖项,以及其他依赖项,例如您需要单独添加的插件。使用针对插件的相同版本。例如,要添加约定插件使用
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.3.8</version>
</dependency>我选择的目标版本号为2.3.8,但它可能与其他特性(即Hibernate和Spring )不兼容,这些特性需要通过向依赖项添加相应的工件来单独升级。
最后,也是最耗时的是修改项目的源代码,根据更新的DTD、API更改、修复废弃更新配置文件。为此,请考虑阅读发布说明。
还请参阅开发Maven项目的示例:使用Maven创建Struts 2 Web应用程序来管理工件和构建应用程序。
https://stackoverflow.com/questions/17821441
复制相似问题