Maven使用总结

Maven使用总结

1、pom.xml文件中添加新的库

在中央仓库找不到你想要的jar的时候,可以在pom.xml中添加附加的库,语法如下

2、我们在maven install的时候,有些时候其实并不需要顺带执行test动作,这是后可以修改pom文件跳过test步骤

3、Failure to transfer xmlpull:xmlpull:jar:1.1.3.1 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact xmlpull:xmlpull:jar:1.1.3.1 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled.

出现类似这样的报错,但是maven install 有不管用,可知是本地仓库的缓存(cached)造成,到本地中央仓库的对应目录下把 xxx.lastUpdated文件全部删掉,重新运行maven即可。

或者在用maven时加 -U参数,就可以忽略xxx.lastUpdated.

原文链接:https://www.cnblogs.com/mingziday/p/4659487.html

SSM开发环境搭建一条龙

1.创建一个maven工程
2.开始导入需要的jar包(http://mvnrepository.com)

<br /> <!--spring 的5个核心依赖 --><br /> <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans --><br /> <dependency><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-beans</artifactId><br /> <version>${springframework.version}</version><br /> </dependency><br /> <!--spring 的上下文依赖 --><br /> <dependency><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-context</artifactId><br /> <version>${springframework.version}</version><br /> </dependency><br /> <!--springMvc+spring web引入 --><br /> <dependency><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-web</artifactId><br /> <version>${springframework.version}</version><br /> </dependency><br /> <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --><br /> <dependency><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-webmvc</artifactId><br /> <version>${springframework.version}</version><br /> </dependency><br /> <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc --><br /> <dependency><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-jdbc</artifactId><br /> <version>${springframework.version}</version><br /> </dependency><br /> <!--mybatis相关的包 --><br /> <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis --><br /> <dependency><br /> <groupId>org.mybatis</groupId><br /> <artifactId>mybatis</artifactId><br /> <version>3.4.0</version><br /> </dependency><br /> <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring --><br /> <dependency><br /> <groupId>org.mybatis</groupId><br /> <artifactId>mybatis-spring</artifactId><br /> <version>1.2.3</version><br /> </dependency><br /> <!--druid --><br /> <!-- https://mvnrepository.com/artifact/com.alibaba/druid --><br /> <dependency><br /> <groupId>com.alibaba</groupId><br /> <artifactId>druid</artifactId><br /> <version>1.1.6</version><br /> </dependency><br /> <!--mysql --><br /> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --><br /> <dependency><br /> <groupId>mysql</groupId><br /> <artifactId>mysql-connector-java</artifactId><br /> <version>5.1.30</version><br /> </dependency><br /> <!--lombok 考虑到实际代码可阅读性这里不做引入仅供参考 --><br /> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --><br /> <!-- <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.18</version> <scope>provided</scope> </dependency> --><br /> <!--jackson --><br /> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-guava --><br /> <dependency><br /> <groupId>com.fasterxml.jackson.datatype</groupId><br /> <artifactId>jackson-datatype-guava</artifactId><br /> <version>2.9.0</version><br /> </dependency><br />