Preface: Building Web Development Environment with IntelliJ IDEA and Maven Management (Take Spring MVC as an example) (1) How to build the web infrastructure environment has been introduced. Here we mainly demonstrate how to build the spring environment, and then combine it into a completed spring MVC Web project.
Build Spring environment.
1. With Maven, you can easily configure the spring environment. The specific pom file is shown below.
<!--Setting Version Information--> <properties> <file.encoding>UTF-8</file.encoding> <spring.version>4.2.1.RELEASE</spring.version> <mysql.version>5.1.20</mysql.version> <servlet.version>2.5</servlet.version> <commons-dbcp.version>1.4</commons-dbcp.version> <commons-pool.version>1.4</commons-pool.version> <aspectj.version>1.8.1</aspectj.version> </properties> <!--Define dependency--> <dependencies> <!--spring Dependent dependence--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</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-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> <!-- Database-driven dependencies--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <!-- Connection pool dependency--> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>${commons-dbcp.version}</version> </dependency> <dependency> <groupId>commons-pool</groupId> <artifactId>commons-pool</artifactId> <version>${commons-pool.version}</version> </dependency> <!-- web Class library dependency--> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>${servlet.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!-- Log dependency--> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.17</version> <configuration> <parallel>methods</parallel> <threadCount>10</threadCount> </configuration> </plugin> </plugins> </build>
Note: In addition to the jar packages required by spring, the pom files also configure dependencies on database drivers and other related information.
2. Create a spring configuration file in the Resource directory, as shown in the following figure.
3. Due to the need to demonstrate a relatively complete Spring MVC Web project,