java
JDK配置 CLASSPATH .;%JAVA_HOME%\BIN;%JAVA_HOME\lib\dt.jar;%JAVA_HOME%\lib\tools.jar JAVA_HOME C:\Program Files\Java\jdk1.8.0_181 path %JAVA_HOME%\bin %JAVA_HOME%\jre\bin 官网 https://spring.io/guides/gs/spring-boot/ https://spring.io/projects/spring-boot 包构建 https://start.spring.io/ 版本 https://blog.csdn.net/qq_41160301/article/details/124606068 @JsonIgnore 忽略此属性,比如password我并不想返回给前端,就可以添加此注解,属性就不会被Jackson序列化和反序列化。 @JsonFormat(pattern = “yy-MM-dd HH:mm:ss a”, locale = “zh”, timezone = “GMT+8”) 时间日期输出格式化。 **@JsonInclude(JsonInclude.Include.NON_NULL) ** 如果字段为null不返回该字段的数据。 **@JsonProperty(value = “user_name”) ** 注解指定一个属性用于JSON映射,默认情况下映射的JSON属性与注解的属性名称相同,不过可以使用该注解的value值修改JSON属性名,该注解还有一个index属性指定生成JSON属性的顺序,如果有必要的话。 @JsonIgnoreProperties 注解是类注解,在序列化为json的时候 @JsonIgnoreProperties({“prop1”,“prop2”}) 则会忽略pro1和pro2这两个属性。 在JSON反序列化为java类的时候@JsonIgnoreProperties(ignoreUnknown = true) 会忽略所有没有getter和seteer的属性,该注解在java属性和json不匹配的时候很有用。 @JsonUnwrapped(prefix=“user”) 把成员对象中的属性提升到自己的容器中。 **@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,property = “id”) ** 作用于类或属性上,被用来在序列化/反序列化时为该对象或字段添加一个对象识别码,通常是用来解决循环嵌套的问题 在jpa中会经常出现这种问题。 @JsonIgnoreType 也是类注解,会排除所有指定类型的属性。 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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.0</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>stringboot</artifactId> <version>0.0.1-SNAPSHOT</version> <name>stringboot</name> <description>Demo project for Spring Boot</description> <properties> <java.version>18</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork><!--必须添加这个配置--></configuration> </plugin> </plugins> </build> </project>
mybatis
https://mvnrepository.com/artifact/org.mybatis/mybatis/3.5.5
https://mybatis.org/mybatis-3/
<?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>net.class</groupId>
<artifactId>xd-my</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
</dependencies>
</project>
mybatis-config
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/><dataSource type="POOLED">
<property name="driver" value="com.mysglcjjdbc.Driver"/>
<property name="url" value="jdbcmys1://127.0.01:3306/xdclas?useUnicode=trueamp;characterEncoding-utf-8&useSSL=false"/>
<property name="username" value="root"/>
<property name="password" value="xdclass.net"/></dataSource></environment></environments><mappers>
<mapper resource="mapper/VideoMapper.xml"/>
</mappers>
</configuration>