mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2025-01-03 17:42:20 +08:00
fix:移除jackson序列化导致程序报错问题
This commit is contained in:
parent
d219d05053
commit
17865c9454
13
README.md
13
README.md
@ -9,9 +9,7 @@ youlai-mall是集成当前最新主流技术一套开源的商城系统。整个
|
|||||||
|
|
||||||
**线上地址:** [www.youlai.store](http://www.youlai.store)
|
**线上地址:** [www.youlai.store](http://www.youlai.store)
|
||||||
|
|
||||||
### 后台
|
### 管理后台
|
||||||
|
|
||||||
体验码,加我微信(微信号:haoxianrui)备注“体验”获取体验资格
|
|
||||||
|
|
||||||
![](https://i.loli.net/2021/01/02/7t9TlgCHSnam64E.png)
|
![](https://i.loli.net/2021/01/02/7t9TlgCHSnam64E.png)
|
||||||
|
|
||||||
@ -20,9 +18,7 @@ youlai-mall是集成当前最新主流技术一套开源的商城系统。整个
|
|||||||
![](https://i.loli.net/2020/12/27/iLw3jEgVGQSf61F.png)
|
![](https://i.loli.net/2020/12/27/iLw3jEgVGQSf61F.png)
|
||||||
|
|
||||||
|
|
||||||
### 小程序
|
### 微信小程序
|
||||||
|
|
||||||
![](https://i.loli.net/2021/01/02/ZesKNr17FBUlWGE.jpg)
|
|
||||||
|
|
||||||
![](https://i.loli.net/2021/01/02/OugrUpPVl9d5w14.png)
|
![](https://i.loli.net/2021/01/02/OugrUpPVl9d5w14.png)
|
||||||
|
|
||||||
@ -30,6 +26,11 @@ youlai-mall是集成当前最新主流技术一套开源的商城系统。整个
|
|||||||
|
|
||||||
![](https://i.loli.net/2021/01/02/QDU9okJbvuVrxwc.png)
|
![](https://i.loli.net/2021/01/02/QDU9okJbvuVrxwc.png)
|
||||||
|
|
||||||
|
|
||||||
|
**体验码,加我微信(微信号:haoxianrui)备注“体验”获取体验**
|
||||||
|
|
||||||
|
![](https://i.loli.net/2021/01/02/ZesKNr17FBUlWGE.jpg)
|
||||||
|
|
||||||
## **项目结构**
|
## **项目结构**
|
||||||
|
|
||||||
``` lua
|
``` lua
|
||||||
|
26
pom.xml
26
pom.xml
@ -103,32 +103,6 @@
|
|||||||
<artifactId>weixin-java-miniapp</artifactId>
|
<artifactId>weixin-java-miniapp</artifactId>
|
||||||
<version>${weixin-java-miniapp.version}</version>
|
<version>${weixin-java-miniapp.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-validator</artifactId>
|
|
||||||
<version>${hibernate-validator.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-annotations</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
@ -16,21 +16,5 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-annotations</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,63 +1,24 @@
|
|||||||
package com.youlai.common.redis;
|
package com.youlai.common.redis;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
|
||||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class RedisConfig {
|
public class RedisConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
||||||
// RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
|
||||||
// redisTemplate.setKeySerializer(new StringRedisSerializer());
|
|
||||||
// redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
|
|
||||||
// redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
|
||||||
// redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
|
|
||||||
// redisTemplate.setConnectionFactory(factory);
|
|
||||||
// redisTemplate.afterPropertiesSet();
|
|
||||||
// return redisTemplate;
|
|
||||||
|
|
||||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||||
|
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||||
|
redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
|
||||||
|
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||||
|
redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
|
||||||
redisTemplate.setConnectionFactory(factory);
|
redisTemplate.setConnectionFactory(factory);
|
||||||
// 用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
|
|
||||||
redisTemplate.setValueSerializer(serializer());
|
|
||||||
|
|
||||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
|
||||||
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
|
||||||
redisTemplate.setKeySerializer(stringRedisSerializer);
|
|
||||||
|
|
||||||
// hash的key也采用String的序列化方式
|
|
||||||
redisTemplate.setHashKeySerializer(stringRedisSerializer);
|
|
||||||
// hash的value序列化方式采用jackson
|
|
||||||
redisTemplate.setHashValueSerializer(serializer());
|
|
||||||
redisTemplate.afterPropertiesSet();
|
redisTemplate.afterPropertiesSet();
|
||||||
return redisTemplate;
|
return redisTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置Jackson2JsonRedisSerializer序列化策略
|
|
||||||
* */
|
|
||||||
private Jackson2JsonRedisSerializer<Object> serializer() {
|
|
||||||
// 使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
|
|
||||||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
|
|
||||||
// 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
|
|
||||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
|
||||||
|
|
||||||
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
|
||||||
|
|
||||||
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
|
|
||||||
// objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
|
||||||
|
|
||||||
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
|
|
||||||
return jackson2JsonRedisSerializer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,18 @@
|
|||||||
package com.youlai.common.web.vo;
|
package com.youlai.common.web.vo;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@ApiModel
|
|
||||||
public class CascaderVO {
|
public class CascaderVO {
|
||||||
|
|
||||||
@ApiModelProperty(name="节点value")
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
@ApiModelProperty(name="节点label")
|
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
@ApiModelProperty(name="子节点")
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
private List<CascaderVO> children;
|
private List<CascaderVO> children;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user