从 Struts2 迁移到 Spring MVC
Migration from Struts2 to Spring MVC
我希望将我的项目从 Struts2 更改为 Spring MVC。
我这样做的动机是双重的:
1 - 我希望我的演示框架能够正确实现 HTML5 标签
2 - 最近被一家使用 Struts2 而没有 Spring 的公司裁员,我现在发现我缺乏找到新工作的技能
我首先使用 maven 原型开始这个项目(我不记得是哪一个)并且 pom 已经配置了以下内容:
<properties>
<struts.version>2.3.1</struts.version>
</properties>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-sitemesh-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
是的,该项目正在使用 Spring,但只是 bean 实例化和依赖项注入的核心。
我想知道的是:
我需要用什么来替换这些依赖项:
维护与 Struts 2.3.1 一起打包的 sitemesh 和 spring 核心版本? (我搜索了 'Struts 2.3.1 bundled packages' 并找到了这个,但 'spring plugin' https://struts.apache.org/docs/guides.html 旁边没有版本)
用 Spring MVC 替换核心和其余插件
我是否需要像 Struts 那样对 spring 的 JSON 支持进行额外的依赖?
我意识到一旦这些被换掉,重构到 Spring 将是一项艰巨的任务。
感谢 Dave Newton 为我指明了正确的方向。
使用
找到答案
mvn dependency:tree
这表明 struts2 spring 插件包括:
+- org.apache.struts:struts2-spring-plugin:jar:2.3.1:compile
| +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
| +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
| | +- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
| | \- commons-logging:commons-logging:jar:1.1.1:compile
| +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
| | +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
| | \- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
| +- org.springframework:spring-web:jar:3.0.5.RELEASE:compile
| | \- aopalliance:aopalliance:jar:1.0:compile
| +- commons-lang:commons-lang:jar:2.5:compile
| \- org.apache.struts:struts2-core:jar:2.3.1:compile
| +- org.apache.struts.xwork:xwork-core:jar:2.3.1:compile
| | +- asm:asm:jar:3.3:compile
| | \- asm:asm-commons:jar:3.3:compile
| | \- asm:asm-tree:jar:3.3:compile
| +- org.freemarker:freemarker:jar:2.3.18:compile
| \- ognl:ognl:jar:3.0.3:compile
| \- javassist:javassist:jar:3.11.0.GA:compile
所以答案:struts 2.3.1 有 spring 核心等版本 3.0.5
我希望将我的项目从 Struts2 更改为 Spring MVC。
我这样做的动机是双重的: 1 - 我希望我的演示框架能够正确实现 HTML5 标签 2 - 最近被一家使用 Struts2 而没有 Spring 的公司裁员,我现在发现我缺乏找到新工作的技能
我首先使用 maven 原型开始这个项目(我不记得是哪一个)并且 pom 已经配置了以下内容:
<properties>
<struts.version>2.3.1</struts.version>
</properties>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-sitemesh-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
是的,该项目正在使用 Spring,但只是 bean 实例化和依赖项注入的核心。
我想知道的是: 我需要用什么来替换这些依赖项: 维护与 Struts 2.3.1 一起打包的 sitemesh 和 spring 核心版本? (我搜索了 'Struts 2.3.1 bundled packages' 并找到了这个,但 'spring plugin' https://struts.apache.org/docs/guides.html 旁边没有版本) 用 Spring MVC 替换核心和其余插件 我是否需要像 Struts 那样对 spring 的 JSON 支持进行额外的依赖?
我意识到一旦这些被换掉,重构到 Spring 将是一项艰巨的任务。
感谢 Dave Newton 为我指明了正确的方向。
使用
找到答案mvn dependency:tree
这表明 struts2 spring 插件包括:
+- org.apache.struts:struts2-spring-plugin:jar:2.3.1:compile
| +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
| +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
| | +- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
| | \- commons-logging:commons-logging:jar:1.1.1:compile
| +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
| | +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
| | \- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
| +- org.springframework:spring-web:jar:3.0.5.RELEASE:compile
| | \- aopalliance:aopalliance:jar:1.0:compile
| +- commons-lang:commons-lang:jar:2.5:compile
| \- org.apache.struts:struts2-core:jar:2.3.1:compile
| +- org.apache.struts.xwork:xwork-core:jar:2.3.1:compile
| | +- asm:asm:jar:3.3:compile
| | \- asm:asm-commons:jar:3.3:compile
| | \- asm:asm-tree:jar:3.3:compile
| +- org.freemarker:freemarker:jar:2.3.18:compile
| \- ognl:ognl:jar:3.0.3:compile
| \- javassist:javassist:jar:3.11.0.GA:compile
所以答案:struts 2.3.1 有 spring 核心等版本 3.0.5