Собственно познаю глубины волокна, и взялся вот за этот мануал:
https://spring.io/guides/gs/rest-service/
Собственно проблема:
o.s.web.servlet.DispatcherServlet : Completed initialization in 2 ms
o.s.web.servlet.DispatcherServlet : GET "/message", parameters={}
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to by.alex.webrest.RESTApp#GetMessage(String)
.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class by.alex.webrest.RESTMessage]
o.s.web.servlet.DispatcherServlet : Completed 500 INTERNAL_SERVER_ERROR
o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/error", parameters={}
s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 500
pom.xml:
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>by.alex</groupId>
<artifactId>webrest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>webrest</name>
<description>Some just REST service</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
RestApp.java:
RESTApp.java
package by.alex.webrest;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@RestController
public class RESTApp {
private static final String template = "Hello, %s";
private final AtomicLong requestCounter = new AtomicLong();
@GetMapping("/message")
@ResponseBody
RESTMessage GetMessage(@RequestParam(name = "name", defaultValue = "my friend!") String target) {
return new RESTMessage(requestCounter.incrementAndGet(), String.format(template, target));
}
}
RESTMessage.java:
RESTMessage.java
package by.alex.webrest;
public class RESTMessage {
private final long id;
private final String content;
RESTMessage(long id, String content) {
this.id = id;
this.content = content;
}
long getId() {
return this.id;
}
String getContent() {
return this.content;
}
}
WebRestApplication.java:
WebRestApplication.java
package by.alex.webrest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
@SpringBootApplication
public class WebrestApplication {
public static void main(String[] args) {
SpringApplication.run(WebrestApplication.class, args);
}
}
Пробовал советы из интернетов:
1. Удалять .m2 репозиторий с ПК
2. добавить jackson.fastxml в pom.xml
НЕ ПОМОГЛО
так грусно когда их гайды не работают....