準備工做:
安裝idea intellij
安裝jdk1.8,配好環境變量
安裝tomcat 7html
準備工做完成以後,就開始建立項目了java
1.File–>new project–>選擇maven–>webapp ,填好公司名稱和項目名稱,而後一路默認mysql
這個是建立好的默認目錄web
maven仍是很方便的,只須要在根目錄下的pom.xml文件中加入須要的依賴包版本信息,就能夠自動下載導入全部的包,先來看一下pom.xml的目錄結構:spring
<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>sikang</groupId> <artifactId>sk</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>sk Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <!-- spring版本號 --> <spring.version>4.3.1.RELEASE</spring.version> </properties> <!-- 依賴從這開始 <dependencies>是全部依賴包的父級標籤 其中每添加一個依賴包,就加一個<dependency>標籤 這裏已經默認添加了一個測試包,咱們須要把全部用到的依賴所有進來 (用到每一個包的依賴信息須要本身找,下面是這個demo須要的依賴包) --> <!--項目依賴 --> <dependencies> <!--日誌包--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.21</version> </dependency> <!--j2ee相關包 servlet、jsp、jstl--> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!--mysql驅動包--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.35</version> </dependency> <!-- 添加Hibernate依賴 --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>3.6.0.Final</version> </dependency> <!-- https://mvnrepository.com/artifact/javassist/javassist --> <dependency> <groupId>javassist</groupId> <artifactId>javassist</artifactId> <version>3.12.1.GA</version> </dependency> <!--spring相關包--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>${spring.version}</version>