复制jar包可能出现的问题
复制过程如果出现unknown爆红。
解决
1、确保maven仓库中有这个包
2、将.m2仓库中的文件删除重新刷新:
3、如果发现还是unknown(可能是我们直接复制了 pom.xml)
可能原因:复制过程中,‘-’ 符号会被操作系统缓存为U+2010符号,存入utf-8的pom文件后,该符号会被编码为0xe28090,这样一来,简单的一行文字 spring-boot-starter-web中所有的- 号就会出现编码错误。maven仓库是绝对找不到这样的jar包的。然而,idea文本编辑器显示的效果和正确的-号一样
解决:1、手动敲,2、ctrl + r,将 ‘-’ 重新替换一下;
注意下面是Maven管理的jar包
如果单独导入jar包,下面的可能不适用
<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.zy</groupId> <artifactId>工程8</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <dependencies> </dependencies> </project>
spring 核心
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.3.17.RELEASE</version> </dependency>
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring-webmvc.version}</version> </dependency>
spring MVC:如果导入了spring MVC,包含spring-web,spring-context,spring-aop
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.3.17.RELEASE</version> </dependency>
spring 整合web:如果导入了spring MVC不需要在导入这个包,maven依赖spring MVC的时候,会自动依赖spring web
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.3.17.RELEASE</version> </dependency>
Servlet
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <scope>provided</scope> </dependency>
jdbc
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>5.1.8.RELEASE</version> </dependency>
mysql 驱动
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.47</version> </dependency>
MongoDB驱动
<!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver --> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>3.11.1</version> </dependency>
junit 测试
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13-beta-2</version> </dependency> <!--测试--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> //需要和spring项目版本一致 <version>4.1.7.RELEASE</version> </dependency>
c3p0连接池
<dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>0.9.5.4</version> </dependency>
dpcp 连接池
<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-dbcp2</artifactId> <version>2.6.0</version> </dependency> <!--dpcp 连接池需要依赖,maven管理包中,这个就不要添加了--> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> <version>2.6.2</version> </dependency>
AOP:全自动配置代理
<dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.9.4</version> </dependency>
spring mvc 文件上传
<dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.4</version> </dependency>
cglib:mybatis使用延迟加载时,配置的;
<dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>3.2.12</version> </dependency>
Mybatis和spring整和
<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.8</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> //和spring版本保持一致 <version>4.3.17.RELEASE</version> </dependency>
fastjson:将对象序列化成json数据
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.62</version> </dependency>
使用
public static void main(String[] args) { Map<String,Object> json=new HashMap<>(); json.put("id",1); json.put("sn", "33"); String string = JSONObject.toJSONString(json); //JSONObject.toJavaObject(); 可以将json数据转变成java对象 System.out.println(string); //{"id":1,"sn":"33"} }