Skip to content

Commit b77d0e6

Browse files
committedSep 20, 2023
Add support for SpringBoot 3
1 parent e00a074 commit b77d0e6

File tree

17 files changed

+739
-6
lines changed

17 files changed

+739
-6
lines changed
 

‎docs/spring-boot-support.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ The `server.xml` provided by the `serverXmlFile` parameter or located in the `co
1515
| Feature | Description |
1616
| ------- | ----------- |
1717
| springBoot-1.5 | Required to support applications with Spring Boot version 1.5.x. |
18-
| springBoot-2.0 | Required to support applications with Spring Boot version 2.0.x and above. |
18+
| springBoot-2.0 | Required to support applications with Spring Boot version 2.0.x. |
19+
| springBoot-3.0 | Required to support applications with Spring Boot version 3.x. |
1920

2021
The Liberty features that support the Spring Boot starters can be found [here](https://www.ibm.com/support/knowledgecenter/SSAW57_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/rwlp_springboot.html). They should be enabled in the `server.xml` along with the appropriate Spring Boot feature.
2122

23+
### Java Support
24+
25+
The Spring Boot version 3.x requires Java 17 or above.
26+
2227
### Example
2328

2429
To use the `liberty-maven-plugin` to install a Spring Boot application packaged as a Spring Boot Uber JAR, include the appropriate XML in the `plugins` section of your `pom.xml`.

‎liberty-maven-plugin/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223
<configuration>
224224
<pomExcludes>
225225
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
226+
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
226227
</pomExcludes>
227228
</configuration>
228229
</plugin>
@@ -262,6 +263,7 @@
262263
<pomExclude>server-param-configdir-not-override-it/pom.xml</pomExclude>
263264
<pomExclude>install-features-it/pom.xml</pomExclude>
264265
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
266+
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
265267
</pomExcludes>
266268
</configuration>
267269
</plugin>
@@ -300,6 +302,7 @@
300302
<pomExclude>dev-it/pom.xml</pomExclude>
301303
<pomExclude>generate-features-it/pom.xml</pomExclude>
302304
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
305+
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
303306
</pomExcludes>
304307
</configuration>
305308
</plugin>
@@ -343,6 +346,7 @@
343346
<pomExclude>install-features-it/pom.xml</pomExclude>
344347
<pomExclude>generate-features-it/pom.xml</pomExclude>
345348
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
349+
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
346350
</pomExcludes>
347351
</configuration>
348352
</plugin>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
4+
xmlns="http://maven.apache.org/POM/4.0.0"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6+
7+
<modelVersion>4.0.0</modelVersion>
8+
9+
<parent>
10+
<groupId>io.openliberty.tools.it</groupId>
11+
<artifactId>tests</artifactId>
12+
<version>1.0-SNAPSHOT</version>
13+
</parent>
14+
15+
<artifactId>springboot-3-tests</artifactId>
16+
<packaging>pom</packaging>
17+
18+
<properties>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
21+
<maven.compiler.source>17</maven.compiler.source>
22+
<maven.compiler.target>17</maven.compiler.target>
23+
</properties>
24+
25+
<modules>
26+
<module>springboot-3-appsdirectory-apps-it</module>
27+
<module>springboot-3-appsdirectory-dropins-it</module>
28+
</modules>
29+
30+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<artifactId>springboot-3-appsdirectory-apps-it</artifactId>
7+
<version>1.0.0.Final</version>
8+
<packaging>jar</packaging>
9+
10+
<parent>
11+
<groupId>org.springframework.boot</groupId>
12+
<artifactId>spring-boot-starter-parent</artifactId>
13+
<version>3.1.3</version>
14+
<relativePath /> <!-- lookup parent from repository -->
15+
</parent>
16+
17+
<properties>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
20+
<maven.compiler.source>17</maven.compiler.source>
21+
<maven.compiler.target>17</maven.compiler.target>
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-web</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.springframework.boot</groupId>
31+
<artifactId>spring-boot-starter-test</artifactId>
32+
<scope>test</scope>
33+
</dependency>
34+
<dependency>
35+
<groupId>junit</groupId>
36+
<artifactId>junit</artifactId>
37+
<version>4.13.2</version>
38+
<scope>test</scope>
39+
</dependency>
40+
<!-- Support for JDK 9 and above-->
41+
<dependency>
42+
<groupId>javax.xml.bind</groupId>
43+
<artifactId>jaxb-api</artifactId>
44+
<version>2.3.1</version>
45+
<scope>provided</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>com.sun.xml.bind</groupId>
49+
<artifactId>jaxb-core</artifactId>
50+
<version>2.3.0.1</version>
51+
<scope>provided</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>javax.activation</groupId>
55+
<artifactId>activation</artifactId>
56+
<version>1.1.1</version>
57+
<scope>provided</scope>
58+
</dependency>
59+
</dependencies>
60+
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-maven-plugin</artifactId>
66+
<!-- Test support for classifier configuration parameter -->
67+
<configuration>
68+
<classifier>exec</classifier>
69+
</configuration>
70+
</plugin>
71+
72+
<plugin>
73+
<groupId>io.openliberty.tools</groupId>
74+
<artifactId>liberty-maven-plugin</artifactId>
75+
<version>@pom.version@</version>
76+
77+
<!-- Specify configuration, executions for liberty-maven-plugin -->
78+
<configuration>
79+
<serverName>test</serverName>
80+
<serverXmlFile>src/test/resources/server.xml</serverXmlFile>
81+
<runtimeArtifact>
82+
<groupId>${runtimeGroupId}</groupId>
83+
<artifactId>${runtimeArtifactId}</artifactId>
84+
<version>23.0.0.9</version>
85+
<type>zip</type>
86+
</runtimeArtifact>
87+
<appsDirectory>apps</appsDirectory>
88+
<deployPackages>spring-boot-project</deployPackages>
89+
</configuration>
90+
91+
<executions>
92+
<execution>
93+
<id>stop-server-before-clean</id>
94+
<phase>pre-clean</phase>
95+
<goals>
96+
<goal>stop</goal>
97+
</goals>
98+
</execution>
99+
<execution>
100+
<id>create-server</id>
101+
<phase>prepare-package</phase>
102+
<goals>
103+
<goal>install-server</goal>
104+
<goal>create</goal>
105+
<goal>install-feature</goal>
106+
</goals>
107+
</execution>
108+
<execution>
109+
<id>install-apps</id>
110+
<phase>package</phase>
111+
<goals>
112+
<goal>deploy</goal>
113+
</goals>
114+
</execution>
115+
<execution>
116+
<id>test-start-server</id>
117+
<phase>pre-integration-test</phase>
118+
<goals>
119+
<goal>test-start</goal>
120+
</goals>
121+
</execution>
122+
<execution>
123+
<id>test-stop-server</id>
124+
<phase>post-integration-test</phase>
125+
<goals>
126+
<goal>test-stop</goal>
127+
</goals>
128+
</execution>
129+
</executions>
130+
</plugin>
131+
132+
<plugin>
133+
<artifactId>maven-failsafe-plugin</artifactId>
134+
<version>3.1.2</version>
135+
<configuration>
136+
<runOrder>alphabetical</runOrder>
137+
</configuration>
138+
<executions>
139+
<execution>
140+
<id>default-integration-test</id>
141+
<phase>integration-test</phase>
142+
<goals>
143+
<goal>integration-test</goal>
144+
</goals>
145+
</execution>
146+
<execution>
147+
<id>default-verify</id>
148+
<phase>verify</phase>
149+
<goals>
150+
<goal>verify</goal>
151+
</goals>
152+
</execution>
153+
</executions>
154+
</plugin>
155+
</plugins>
156+
</build>
157+
158+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* (C) Copyright IBM Corporation 2023.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package application;
18+
19+
import org.springframework.boot.SpringApplication;
20+
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
import org.springframework.web.bind.annotation.RequestMapping;
22+
import org.springframework.web.bind.annotation.RestController;
23+
24+
@SpringBootApplication
25+
@RestController
26+
public class SpringBootApp {
27+
public static void main(String[] args) {
28+
SpringApplication.run(SpringBootApp.class, args);
29+
}
30+
31+
@RequestMapping("/spring")
32+
public String hello() {
33+
return "HELLO SPRING BOOT!!";
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* (C) Copyright IBM Corporation 2023.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package application;
17+
18+
import static org.junit.Assert.*;
19+
20+
import java.io.File;
21+
import org.junit.Test;
22+
23+
public class InstallSpringBoot30AppIT {
24+
25+
@Test
26+
public void testThinApplicationExistsInAppsDirectory() throws Exception {
27+
28+
File f = new File("target/liberty/wlp/usr/servers/test/apps/thin-springboot-3-appsdirectory-apps-it-1.0.0.Final-exec.jar");
29+
assertTrue(f.getCanonicalFile() + " doesn't exist. Plugin failed to place the file at right destination.", f.exists());
30+
}
31+
32+
@Test
33+
public void testLibIndexCacheExists() throws Exception {
34+
File f = new File("target/liberty/wlp/usr/shared/resources/lib.index.cache");
35+
assertTrue(f.getCanonicalFile()+ " doesn't exist. Plugin failed to place the cache directory at right destination.", f.exists());
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* (C) Copyright IBM Corporation 2023.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package application;
17+
18+
import static org.junit.Assert.*;
19+
20+
import java.io.BufferedReader;
21+
import java.io.InputStreamReader;
22+
import java.net.HttpURLConnection;
23+
import java.net.URL;
24+
25+
import org.junit.Test;
26+
27+
public class SpringBoot30RestEndpointIT {
28+
29+
@Test
30+
public void testSpringRestBootEndpoint() throws Exception {
31+
32+
URL requestUrl = new URL("http://localhost:9080/spring/");
33+
HttpURLConnection conn = (HttpURLConnection) requestUrl.openConnection();
34+
35+
if (conn != null) {
36+
assertEquals("Expected response code not found.", 200, conn.getResponseCode());
37+
}
38+
39+
StringBuffer response = new StringBuffer();
40+
41+
try (BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
42+
String line;
43+
while ((line = in.readLine()) != null) {
44+
response.append(line);
45+
}
46+
}
47+
assertEquals("Expected body not found.", "HELLO SPRING BOOT!!", response.toString());
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<server description="new server">
3+
4+
<!-- Enable features -->
5+
<featureManager>
6+
<feature>springBoot-3.0</feature>
7+
<feature>servlet-6.0</feature>
8+
</featureManager>
9+
10+
<!-- To access this server from a remote client add a host attribute to
11+
the following element, e.g. host="*" -->
12+
<httpEndpoint httpPort="9080" httpsPort="9443"
13+
id="defaultHttpEndpoint" />
14+
</server>

0 commit comments

Comments
 (0)
Please sign in to comment.