基于Intellij IDEA搭建
Intellij IDEA是Java最优秀的开发工具:功能全面,提示只能,开发不卡顿,新技术支持快。在业界对Intellij的好评也非常多,使用的人也不在少数,经常使用Eclipse的也可能会转向Intellij,所以我认为i对于使用Intellij来搭建Spring项目也是需要掌握。
新建Maven项目。单机File→New→Project→Maven
输入包名、项目名
选择存储路径
修改pom.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxgg</groupId>
<artifactId>spring4_demo</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Intellij IDEA设置自动导入包
File→Settings→Editor→General→Auto Import
勾选Optimize imports on the fly和Add unambiguous imports on the fly
Optimize imports on the fly:自动去掉一些没有用到的包
Add unambiguous imports on the fly:自动帮我们优化导入的包
依赖树查看