springboot 学习问题
At least one JPA metamodel must be present!
参考一:
https://www.cnblogs.com/guwan/p/7901535.html
https://blog.csdn.net/wangjie919/article/details/80347375
2. 结合redis 时, springboot2.0 整合参考
https://blog.csdn.net/sy793314598/article/details/80719224
https://blog.csdn.net/Code_shadow/article/details/81277245
RedisCacheManager 的使用已经发生变化
配置: redisTemplate
@Bean(name = "redisTemplate")
public RedisTemplate<String,Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){
RedisTemplate<String,Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
redisTemplate.setKeySerializer(keySerializer());
redisTemplate.setHashKeySerializer(keySerializer());
redisTemplate.setValueSerializer(valueSerializer());
redisTemplate.setHashValueSerializer(valueSerializer());
return redisTemplate;
}
private RedisSerializer<String> keySerializer() {
return new StringRedisSerializer();
}
private RedisSerializer<Object> valueSerializer() {
return new GenericJackson2JsonRedisSerializer();
}
配置: connectionFactory
@Bean(name = "connectionFactory")
public JedisConnectionFactory initConnect(){
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.afterPropertiesSet();
return connectionFactory;
}
问题
nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool2/impl/GenericObjectPoolConfig
java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoolConfig
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
session 共享问题
正常启动应用有对应数据
启动测试类,session共享没有启动,目前还未找到测试类为什么没有启动
问题
Multiple session repository candidates are available
org.springframework.boot.autoconfigure.session.NonUniqueSessionRepositoryException
使用了mysql 和redis 当数据源保存
去除redis 使用jar包
<!-- redis session 共享 -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
<version>1.3.2.RELEASE</version>
</dependency>
可以在application.properties 设置StoreType 解决
https://www.cnblogs.com/GoodHelper/p/6260708.html
spring.session.store-type= # Session store type.
问题 spring-boot-devtools
热部署功能
<!--添加依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<!-- optional=true,依赖不会传递,该项目依赖devtools;之后依赖myboot项目的项目如果想要使用devtools,需要重新引入 -->
<optional>true</optional>
</dependency>
问题: springboot 结合mybatis配置 使用xml 失效
解决方案
https://blog.csdn.net/ZaberyJava/article/details/82111243?utm_source=blogxgwz0
在application.properties 中添加如下配置
springboot的配置文件 添加:
mybatis.configuration.mapUnderscoreToCamelCase=true 或
mybatis.configuration.map-underscore-to-camel-case=true(根据版本不同)