您的位置:首页 > 编程语言 > Java开发

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

2016-03-04 12:51 543 查看


maven 项目导入eclipse有时候不会自己更新jar 解决方法:

1.下载安装maven 
2.进入项目根目录打开cmd 运行mvn eclipse:eclipse 就会自动下载包


《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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

<projectxmlns="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







 

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

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









5、编译安装项目





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





 

7、启动tomcat,访问首页

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





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

《Spring in action》3rd真是本好书,带我进入了深入理解Spring的大门,感谢作者。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring