《Spring in action》3rd中SpringPizza项目和其他的不同,使用gradle编译的,尝试了好久都没能run起来,最后按照一篇文章的做法,将其转换成maven项目,然后就执行成功了。

1、下载代码

下载地址:http://www.manning.com/walls4/sia3-code.zip,解压代码

2、在\sia3-code\SpringPizza目录下建立pom.xml文件,把项目变成maven编译

pom.xml文件内容如下:

在SpringPizza目录下建立pom.xml文件

XHTML


<project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns : xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi : schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
<modelVersion> 4.0.0 </modelVersion>
<groupId> com.yogesh </groupId>
<artifactId> SpringPizza </artifactId>
<packaging> war </packaging>
<version> 1.0-SNAPSHOT </version>
<name> spring-web-flow Maven Webapp </name>
<url> http://maven.apache.org </url>
<properties>
<spring.version> 3.0.5.RELEASE </spring.version>
</properties>

<dependencies>
<dependency>
<groupId> org.springframework.webflow </groupId>
<artifactId> spring-webflow </artifactId>
<version> 2.3.2.RELEASE </version>
</dependency>
<dependency>
<groupId> org.springframework.webflow </groupId>
<artifactId> spring-binding </artifactId>
<version> 2.3.2.RELEASE </version>
</dependency>
<dependency>
<groupId> jstl </groupId>
<artifactId> jstl </artifactId>
<version> 1.2 </version>
</dependency>
<dependency>
<groupId> commons-lang </groupId>
<artifactId> commons-lang </artifactId>
<version> 2.6 </version>
</dependency>
<dependency>
<groupId> org.springframework </groupId>
<artifactId> spring-beans </artifactId>
<version> 3.2.4.RELEASE </version>
</dependency>
<dependency>
<groupId> org.tuckey </groupId>
<artifactId> urlrewritefilter </artifactId>
<version> 3.1.0 </version>
</dependency>
<dependency>
<groupId> log4j </groupId>
<artifactId> log4j </artifactId>
<version> 1.2.7 </version>
</dependency>
<dependency>
<groupId> org.springframework </groupId>
<artifactId> spring-aspects </artifactId>
<version> 2.0-m2 </version>
</dependency>
</dependencies>

<build>
<finalName> SpringPizza </finalName>
<plugins>
<plugin>
<artifactId> maven-compiler-plugin </artifactId>
<version> 2.3.2 </version>
<configuration>
<source> 1.6 </source>
<target> 1.6 </target>
</configuration>
</plugin>
</plugins>
</build>

</project>

3、使用maven项目的方式,导入SpringPizza

《Spring in action》3rd中SpringPizza项目的运行方法_apache

​​

《Spring in action》3rd中SpringPizza项目的运行方法_apache_02


 

导入后发现/SpringPizza/src/test/java/com/springinaction/pizza/flow/PizzaFlowTest.java单测报错,半天没搞定,先删除,对运行项目没有影响;

4、把项目转换成web形式并且添加maven依赖到编译路径

《Spring in action》3rd中SpringPizza项目的运行方法_spring_03


《Spring in action》3rd中SpringPizza项目的运行方法_apache_04

5、编译安装项目

《Spring in action》3rd中SpringPizza项目的运行方法_maven_05


6、把编译的项目添加到Server中

《Spring in action》3rd中SpringPizza项目的运行方法_maven_06


 

7、启动tomcat,访问首页

地址是:http://localhost:8080/SpringPizza/pizza

《Spring in action》3rd中SpringPizza项目的运行方法_maven_07


这样就可以结合代码和执行,来仔细研究web flow的代码了。

《Spring in action》3rd真是本好书,带我进入了深入理解Spring的大门,感谢作者。