1. 当Springboot项目启动时,程序没有遇到报错就停止
-引入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2. 引入redis的问题
-依赖
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
2.1 springboot 整合redis
参考文章实现
https://blog.csdn.net/zhulier1124/article/details/82154937
1/读取yml配置的问题
@ConfigurationProperties 与 @Value公用,因为树的层级较多,无法用prefix全部覆盖
application.yml文件
spring:
redis:
host: localhost
port: 6379
timeout: 10000
jedis:
pool:
min-idle: 2
max-idle: 8
max-active: 10
config.java文件
@Component
@ConfigurationProperties(prefix = "spring.redis",ignoreUnknownFields = true)
@Slf4j
@Data
public class RedisConfig {
private String host;
private Integer port;
@Value("${spring.redis.jedis.pool.max-active}")
private Integer maxTotal;
//只能用权限定名获取配置信息
@Value("${spring.redis.jedis.pool.max-idle}")
private Integer maxIdle;
@Value("${spring.redis.jedis.pool.min-idle}")
private Integer minIdle;
private Integer timeout;
}
2/ 反序列化报错 Consider defining a bean of type 'xxx' in your configuration问题
解决方法
https://blog.csdn.net/a532672728/article/details/77702772?utm_source=blogxgwz0
3.springboot整合Mybatis
1/使用mybatis generator
依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.9</version>
</dependency>
文件标配
2/无法找到mapper问题
对mapper使用@mapper注解
application.yml
mybatis:
mapper-locations: classpath:mapperss/*.xml
#注意:一定要对应mapper映射xml文件的所在路径
type-aliases-package: com.imooc.user.pojo # 注意:对应实体类的路径
3/cookie注入
java.lang.IllegalArgumentException: An invalid domain [.test.com] was specified for this cookie
网友评论