1. 程式人生 > >Spring整合Struts2和Hibernate+Maven(一)之Maven專案建立

Spring整合Struts2和Hibernate+Maven(一)之Maven專案建立

趁著畢設的功夫,寫一些東西。也算是記錄個人平時畢設完成的過程。

建立專案

工具:intellij idea+JDK1.6+Maven
第一步:New Project ->點選左側maven ->勾選Create fromarchetype 後選擇maven-archetype-webapp點選next ->填寫GroupId和ArtifactId(任意名稱)點選next ->填寫專案名稱點選finish。
第二步:建立專案完成後如圖所示:
這裡寫圖片描述
第三步:我們最先需要關心的一個檔案pom.xml。它是maven管理我們專案的一個xml檔案,我所整理的jar包格式如下:

<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>hgjy</groupId>
  <artifactId>hgjy1</artifactId
>
<packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>hgjy1 Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId
>
<version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.2.3</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-tiles-plugin</artifactId> <version>2.3.15</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.31</version> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-jsp</artifactId> <version>2.0.6</version> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.5.Final</version> <!--<version>3.6.10.Final</version>--> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.1-api</artifactId> <version>1.0.0.Final</version> </dependency> <!--spring mvc--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.0.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.0.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>4.0.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> <version>0.9.1.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>4.1.6.RELEASE</version> </dependency> </dependencies> <build> <finalName>hgjy1</finalName> </build> </project>

以上為建立專案所涉及的一些知識,接下來會用已搭建好的專案繼續講解如何Spring整合Struts2和Hibernate