这里接着上一篇来
我们观察目录发现有两个pom.xml(project object module)
项目是里面的,所以外面的先不管它。
点击里面的pom.xml
1.在<url>节点下面加入阿里云仓库
- <!--仓库-->
- <repositories>
- <repository>
- <id>central repository</id>
- <name>Central</name>
- <url>http://maven.aliyun.com</url>
- </repository>
- </repositories>
2.修改原有的junit依赖
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.3</version>
- <scope>test</scope>
- </dependency>
3.加入log4j依赖
打开http://maven.aliyun.com
搜索log4j,复制节点
或者百度
点击使用量最多的1.2.17
复制节点
粘贴到<dependencies>节点里,然后idea会自动下载jar包到maven的本地仓库,下载完成后<version>节点由红色变为白色,如果本地仓库有,就不用下载啦。
4.如法炮制,下载你需要的jar包到你的本地仓库吧
这里我下载了以下依赖,如果某个依赖不好用,就下载邻近版本的依赖吧。比如mysql-connector-java 5.1.38的依赖如果不好用,就换5.1.39
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.3</version>
- <scope>test</scope>
- </dependency>
- <!-- https://mvnrepository.com/artifact/log4j/log4j -->
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis</artifactId>
- <version>3.4.1</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.39</version>
- </dependency>
5.修改<build>节点
- <build>
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <!--** 无限级目录,src/main/java下所有包的xml文件都加入resources-->
- <include>**/*.xml</include>
- </includes>
- </resource>
- </resources>
- </build>
6.删除外面pom.xml中多余的依赖
下面是引入jar包后的项目结构
来源: http://www.cnblogs.com/tomasman/p/7531436.html