相关疑难解决方法(0)

Java内部类和静态嵌套类

Java中的内部类和静态嵌套类之间的主要区别是什么?设计/实施是否在选择其中一个方面发挥作用?

java inner-classes static-classes

1691
推荐指数
21
解决办法
70万
查看次数

Spring尝试反序列化为LinkedHashMap而不是POJO

我正在使用Spring Boot和Web依赖创建一个简单的休息控制器.我试图将JSON主体反序列化为只有3个字段的测试POJO,但是当我尝试发出POST请求时,服务器响应500错误,我在控制台中得到的错误是:

.w.s.m.s.DefaultHandlerExceptionResolver : Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class java.util.LinkedHashMap
Run Code Online (Sandbox Code Playgroud)

我写的所有代码如下:

EmailApplication.java:

package com.test.email.app;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan(basePackages = { "com.test.email" })
public class EmailApplication {

    public static void main(String[] args) {
        SpringApplication.run(EmailApplication.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {
            System.out.println("----- You're up and running with test-email-app! -----");
        };
    }
}
Run Code Online (Sandbox Code Playgroud)

EmailController.java:

package com.test.email.controller;

import …
Run Code Online (Sandbox Code Playgroud)

java spring jackson spring-boot spring-web

11
推荐指数
1
解决办法
1588
查看次数