Skip to content

Commit 9a5cb08

Browse files
authored
Merge pull request eugenp#4188 from eugenp/spring-boot-2-upgrade
Spring boot 2 upgrade
2 parents 4c86145 + c0131fd commit 9a5cb08

5 files changed

Lines changed: 159 additions & 30 deletions

File tree

‎parent-boot-2/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## Relevant articles:

‎parent-boot-2/pom.xml‎

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.baeldung</groupId>
5+
<artifactId>parent-boot-2</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<packaging>pom</packaging>
8+
<name>Parent Boot 2</name>
9+
<description>Parent for all spring boot 2 modules</description>
10+
11+
<parent>
12+
<groupId>org.springframework.boot</groupId>
13+
<artifactId>spring-boot-starter-parent</artifactId>
14+
<version>2.0.1.RELEASE</version>
15+
<relativePath/>
16+
</parent>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>junit</groupId>
21+
<artifactId>junit</artifactId>
22+
<scope>test</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>io.rest-assured</groupId>
26+
<artifactId>rest-assured</artifactId>
27+
<version>${rest-assured.version}</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.springframework.boot</groupId>
31+
<artifactId>spring-boot-starter-test</artifactId>
32+
<scope>test</scope>
33+
</dependency>
34+
</dependencies>
35+
36+
<build>
37+
<plugins>
38+
<plugin>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-maven-plugin</artifactId>
41+
</plugin>
42+
<plugin>
43+
<groupId>org.apache.maven.plugins</groupId>
44+
<artifactId>maven-surefire-plugin</artifactId>
45+
<version>${maven-surefire-plugin.version}</version>
46+
<configuration>
47+
<forkCount>3</forkCount>
48+
<reuseForks>true</reuseForks>
49+
<excludes>
50+
<exclude>**/*IntegrationTest.java</exclude>
51+
<exclude>**/*LongRunningUnitTest.java</exclude>
52+
<exclude>**/*ManualTest.java</exclude>
53+
<exclude>**/*LiveTest.java</exclude>
54+
</excludes>
55+
</configuration>
56+
</plugin>
57+
<plugin>
58+
<groupId>org.apache.maven.plugins</groupId>
59+
<artifactId>maven-compiler-plugin</artifactId>
60+
<version>${maven-compiler-plugin.version}</version>
61+
<configuration>
62+
<source>${maven.compiler.source}</source>
63+
<target>${maven.compiler.target}</target>
64+
</configuration>
65+
</plugin>
66+
</plugins>
67+
</build>
68+
69+
<profiles>
70+
<profile>
71+
<id>integration</id>
72+
<build>
73+
<plugins>
74+
<plugin>
75+
<groupId>org.apache.maven.plugins</groupId>
76+
<artifactId>maven-surefire-plugin</artifactId>
77+
<executions>
78+
<execution>
79+
<phase>integration-test</phase>
80+
<goals>
81+
<goal>test</goal>
82+
</goals>
83+
<configuration>
84+
<excludes>
85+
<exclude>**/*ManualTest.java</exclude>
86+
<exclude>**/*LiveTest.java</exclude>
87+
<exclude>**/AutoconfigurationTest.java</exclude>
88+
<exclude>**/*UnitTest.java</exclude>
89+
</excludes>
90+
<includes>
91+
<include>**/*IntegrationTest.java</include>
92+
<include>*/EthControllerTestOne.java</include>
93+
<include>**/*IntTest.java</include>
94+
<include>**/*EntryPointsTest.java</include>
95+
</includes>
96+
</configuration>
97+
</execution>
98+
</executions>
99+
<configuration>
100+
<systemPropertyVariables>
101+
<test.mime>json</test.mime>
102+
</systemPropertyVariables>
103+
</configuration>
104+
</plugin>
105+
</plugins>
106+
</build>
107+
</profile>
108+
</profiles>
109+
110+
<properties>
111+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
112+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
113+
<java.version>1.8</java.version>
114+
<rest-assured.version>3.1.0</rest-assured.version>
115+
<!-- plugins -->
116+
<maven.compiler.source>1.8</maven.compiler.source>
117+
<maven.compiler.target>1.8</maven.compiler.target>
118+
</properties>
119+
120+
</project>

‎spring-rest/pom.xml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
<packaging>war</packaging>
99

1010
<parent>
11-
<artifactId>spring-boot-starter-parent</artifactId>
12-
<groupId>org.springframework.boot</groupId>
13-
<version>2.0.1.RELEASE</version>
11+
<artifactId>parent-boot-2</artifactId>
12+
<groupId>com.baeldung</groupId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<relativePath>../parent-boot-2</relativePath>
1415
</parent>
1516

1617
<dependencies>

‎spring-rest/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import org.springframework.beans.factory.annotation.Autowired;
55
import org.springframework.context.annotation.Configuration;
66
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
7-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
7+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
88

99
@Configuration
10-
public class TaxiFareMVCConfig extends WebMvcConfigurerAdapter {
10+
public class TaxiFareMVCConfig implements WebMvcConfigurer {
1111

1212
@Autowired
1313
private TaxiFareRequestInterceptor taxiFareRequestInterceptor;
Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
package org.baeldung.config;
22

3+
import java.text.SimpleDateFormat;
4+
import java.util.List;
5+
36
import org.springframework.context.annotation.ComponentScan;
47
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.http.converter.HttpMessageConverter;
9+
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
10+
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
11+
import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
12+
import org.springframework.oxm.xstream.XStreamMarshaller;
513
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
614
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
715

@@ -17,31 +25,30 @@ public WebConfig() {
1725
super();
1826
}
1927

20-
//
2128
/*
22-
@Override
23-
public void configureMessageConverters(final List<HttpMessageConverter<?>> messageConverters) {
24-
final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
25-
builder.indentOutput(true)
26-
.dateFormat(new SimpleDateFormat("dd-MM-yyyy hh:mm"));
27-
messageConverters.add(new MappingJackson2HttpMessageConverter(builder.build()));
28-
// messageConverters.add(new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(true).build()));
29-
30-
// messageConverters.add(createXmlHttpMessageConverter());
31-
// messageConverters.add(new MappingJackson2HttpMessageConverter());
32-
33-
// messageConverters.add(new ProtobufHttpMessageConverter());
34-
super.configureMessageConverters(messageConverters);
35-
}
36-
37-
private HttpMessageConverter<Object> createXmlHttpMessageConverter() {
38-
final MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter();
39-
40-
final XStreamMarshaller xstreamMarshaller = new XStreamMarshaller();
41-
xmlConverter.setMarshaller(xstreamMarshaller);
42-
xmlConverter.setUnmarshaller(xstreamMarshaller);
43-
44-
return xmlConverter;
45-
}
29+
@Override
30+
public void configureMessageConverters(final List<HttpMessageConverter<?>> messageConverters) {
31+
final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
32+
builder.indentOutput(true)
33+
.dateFormat(new SimpleDateFormat("dd-MM-yyyy hh:mm"));
34+
messageConverters.add(new MappingJackson2HttpMessageConverter(builder.build()));
35+
// messageConverters.add(new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(true).build()));
36+
37+
// messageConverters.add(createXmlHttpMessageConverter());
38+
// messageConverters.add(new MappingJackson2HttpMessageConverter());
39+
40+
// messageConverters.add(new ProtobufHttpMessageConverter());
41+
42+
}
43+
44+
private HttpMessageConverter<Object> createXmlHttpMessageConverter() {
45+
final MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter();
46+
47+
final XStreamMarshaller xstreamMarshaller = new XStreamMarshaller();
48+
xmlConverter.setMarshaller(xstreamMarshaller);
49+
xmlConverter.setUnmarshaller(xstreamMarshaller);
50+
51+
return xmlConverter;
52+
}
4653
*/
4754
}

0 commit comments

Comments
 (0)