Using Redis in JAVA projects Introduce jar package <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <version>2.6.4</version> </dependency> Configure RedisTemplate serializer @Configuration public class RedisTemplateConfig {<!– –> @Bean public RedisTemplate<String, Object> MyRedisTemplate(RedisConnectionFactory connectionFactory) {<!– –> RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(connectionFactory); redisTemplate.setKeySerializer(RedisSerializer.string()); // Use JDK serializer by default // redisTemplate.setValueSerializer(RedisSerializer.java()); redisTemplate.setHashKeySerializer(RedisSerializer.string()); redisTemplate.setHashValueSerializer(RedisSerializer.json()); return redisTemplate; } } Test the serializer […]
Tag: serializer
Exceptionorg.springframework.core.serializer.support.SerializationFailedException
Article directory Environment | Environment Error log | Error log Cause Analysis | Analysis org.springframework.boot.autoconfigure.cache.RedisCacheConfiguration org.springframework.data.redis.serializer.JdkSerializationRedisSerializer org.springframework.core.serializer.support.SerializingConverter org.springframework.core.serializer.DefaultSerializer Solution | Solution Talk is cheap, show me the code. Environment | Environment k version OS windows 10 jdk 1.8 Spring Boot 2.3. 4.RELEASE Error log | Error log 2023-09-15 12:08:33.513 ERROR [http-nio-8080-exec-8] c.i.c.c.GlobalExceptionHandler.handleException(GlobalExceptionHandler.java:88): Error message: Canserialize; […]
59. SpringBoot custom JSON serializer and deserializer
Serialization: The process of saving Java objects in a disk file as a series of bytecodes. It can also be said to be the process of saving the state of Java objects. Serialization can save data permanently on disk (usually in a file). deserialization (deserialization): Reconverting the java bytecode stored in the disk file into […]
Serializers in Django REST framework
Serializers allow complex data such as querysets and model instances to be converted into native Python data types, which can then be easily rendered into JSON, XML, or other content types. Serializers also provide deserialization, which converts parsed data back to complex types after first validating the incoming data. To put it simply, the server […]
[Error] No serializer found for class cn.hutool.json.JSONUll and no properties discovered to create Bea
1. Error content Details: [requestId-] 2023-07-31 18:32:21 |ERROR |http-nio-39978-exec-1 |GlobalExceptionHandler.java:86 |com.xiaobai.base.service.exception.GlobalExceptionHandler |Type definition error: [simple type, class cn.hutool.json.JSONUll]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class cn.hutool.json.JSONUll and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.xiaobai.vo.Result[“result”]->com.baomidou.mybatisplus.extension.plugins.pagination.Page[“records” ]->java.util.ArrayList[2]->cn.hutool.json.JSONObject[“updateTime”]) org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class cn.hutool.json.JSONUll]; nested exception […]
Django rest_framework develops a set of RESTFUL standard interfaces [ModelSerializer+GenericAPIView]
Django rest_framework develops a set of RESTFUL standard interfaces [ModelSerializer + GenericAPIView] No matter how complex the business logic is, no matter how efficient the development framework is, for the backend, it will eventually fall to adding, deleting, modifying and checking a specific relational model. There seems to be no theory, so let’s get started! […]
JsonSerializer business content internationalization based on spring boot
Speaking of internationalization, it is really a cliché. There are various i18n dependent components on the backend, springboot itself also supports i18n settings, and the front-end vue also has i18n settings. I won’t mention these routine operations. You can search other blogs, which are very detailed. This blog is mainly about the internationalization of business […]
Solve JSON serialization error: InvalidDefinitionException: No serializer found for class org.apache.ibatis.executor
Error log: ERROR 17348 — [io-11100-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory$EnhancedResultObjectProxyImpl]; nested except tion is com.fasterxml.jackson .databind.exc.InvalidDefinitionException: No serializer found for class org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory$EnhancedResultObjectProxyImpl and no properties discovered to create BeanSerializer (to avoid exception, […]
DRF-Deserialization of serialization class Serializer-local and global hooks-use of serialization class ModelSerializer
Write 5 interfaces without drf 1.1 Routing urlpatterns = [ path(‘books/’, views. BookView. as_view()), path(‘books/<int:pk>’, views. BookDetailView. as_view()), ] 1.2 View class # Add new book: psot Book query all: get class BookView(View): def get(self, request): books = [] book_list = Book.objects.all() #book_list=[book1,book2] # Assemble into [{name: Journey to the West, pirce: 18}, {name: Journey […]
Five, DRF model serializer ModelSerializer
Previous chapter: 4. Create method and update method of DRF serializer Zero, premise Item table and interface table models.py class Projects(models. Model): id = models.AutoField(primary_key=True, verbose_name=’id primary key’, help_text=’id primary key’) name = models.CharField(max_length=20, verbose_name=’project name’, help_text=’project name’, unique=True) leader = models.CharField(max_length=10, verbose_name=’project leader’, help_text=’project leader’) # c. Use default to specify the default value […]