BAEL-6125 Migrate Application from Spring Boot 2 to Spring Boot 3
This commit is contained in:
parent
20915e1718
commit
9f8926d2aa
@ -0,0 +1,21 @@
|
|||||||
|
package com.baeldung.sample.boundary;
|
||||||
|
|
||||||
|
import org.apache.catalina.connector.Connector;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ServerConfiguration implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customize(TomcatServletWebServerFactory factory) {
|
||||||
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||||
|
@Override
|
||||||
|
public void customize(Connector connector) {
|
||||||
|
connector.setProperty("maxHttpResponseHeaderSize", "100000");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||||
@ -35,6 +36,14 @@ public class TodosController {
|
|||||||
// Mapping zwischen den Schichten
|
// Mapping zwischen den Schichten
|
||||||
private final TodoDtoMapper mapper;
|
private final TodoDtoMapper mapper;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping(value = {"/name"},produces = DEFAULT_MEDIA_TYPE)
|
||||||
|
public List<String> findAllName(){
|
||||||
|
return List.of("Hello", "World");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(produces = DEFAULT_MEDIA_TYPE)
|
@GetMapping(produces = DEFAULT_MEDIA_TYPE)
|
||||||
public Collection<TodoResponseDto> findAll() {
|
public Collection<TodoResponseDto> findAll() {
|
||||||
return service.findAll().stream()
|
return service.findAll().stream()
|
||||||
@ -80,4 +89,5 @@ public class TodosController {
|
|||||||
service.delete(id);
|
service.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.baeldung.sample.boundary;
|
||||||
|
|
||||||
|
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
public class WebConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configurePathMatch(PathMatchConfigurer configurer) {
|
||||||
|
configurer.setUseTrailingSlashMatch(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -215,4 +215,18 @@ class TodosControllerApiIntegrationTest {
|
|||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testGetSlashMatchingNotExisting() throws Exception {
|
||||||
|
mvc
|
||||||
|
.perform(get(BASEURL + "/name/").contentType(DEFAULT_MEDIA_TYPE))
|
||||||
|
.andExpect(status().isNotFound());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testGetNameExists() throws Exception {
|
||||||
|
mvc
|
||||||
|
.perform(get(BASEURL + "/name").contentType(DEFAULT_MEDIA_TYPE))
|
||||||
|
.andExpect(status().isOk());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user