Skip to content

Commit 3658773

Browse files
authored
feat!: migrate apollo server baseline to spring boot 4.0.x (#5585)
* feat!: migrate apollo server baseline to spring boot 4.0.x * docs: add spring boot 4 migration to changes log * build: bump spring boot to 4.0.5
1 parent 56e4821 commit 3658773

107 files changed

Lines changed: 1626 additions & 644 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
#
2+
# Copyright 2026 Apollo Authors
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+
name: external-discovery-smoke
18+
19+
on:
20+
pull_request:
21+
branches: [ master ]
22+
paths:
23+
- 'apollo-configservice/**'
24+
- 'apollo-adminservice/**'
25+
- 'apollo-biz/**'
26+
- 'apollo-common/**'
27+
- 'e2e/**'
28+
- 'scripts/sql/**'
29+
- 'pom.xml'
30+
- '.github/workflows/external-discovery-smoke.yml'
31+
workflow_dispatch:
32+
inputs:
33+
provider:
34+
description: Discovery provider to run
35+
required: false
36+
default: all
37+
type: choice
38+
options:
39+
- all
40+
- nacos
41+
- consul
42+
- zookeeper
43+
44+
jobs:
45+
resolve-provider-matrix:
46+
runs-on: ubuntu-latest
47+
outputs:
48+
providers: ${{ steps.set.outputs.providers }}
49+
steps:
50+
- id: set
51+
shell: bash
52+
run: |
53+
provider="${{ github.event.inputs.provider }}"
54+
if [[ -z "${provider}" || "${provider}" == "all" ]]; then
55+
echo 'providers=["nacos","consul","zookeeper"]' >> "${GITHUB_OUTPUT}"
56+
else
57+
echo "providers=[\"${provider}\"]" >> "${GITHUB_OUTPUT}"
58+
fi
59+
60+
build-services:
61+
runs-on: ubuntu-latest
62+
needs: resolve-provider-matrix
63+
timeout-minutes: 60
64+
steps:
65+
- uses: actions/checkout@v4
66+
67+
- name: Set up JDK 17
68+
uses: actions/setup-java@v4
69+
with:
70+
distribution: temurin
71+
java-version: 17
72+
cache: maven
73+
74+
- name: Build Apollo config/admin services
75+
run: ./mvnw -B -Pnacos-discovery -pl apollo-configservice,apollo-adminservice -am -DskipTests package
76+
77+
- name: Prepare runnable service artifacts
78+
run: |
79+
mkdir -p /tmp/apollo-discovery-artifact
80+
81+
copy_service_jar() {
82+
local service="$1"
83+
local source_jar=""
84+
85+
for candidate in "${service}/target/${service}"-*.jar; do
86+
if [[ "$candidate" == *"-sources.jar" || "$candidate" == *"-javadoc.jar" ]]; then
87+
continue
88+
fi
89+
if [[ -f "$candidate" ]]; then
90+
source_jar="$candidate"
91+
break
92+
fi
93+
done
94+
95+
if [[ -z "$source_jar" ]]; then
96+
echo "No runnable ${service} jar found in ${service}/target" >&2
97+
exit 1
98+
fi
99+
100+
cp "$source_jar" "/tmp/apollo-discovery-artifact/${service}.jar"
101+
}
102+
103+
copy_service_jar "apollo-configservice"
104+
copy_service_jar "apollo-adminservice"
105+
106+
- name: Upload runnable service artifacts
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: apollo-discovery-jars
110+
path: /tmp/apollo-discovery-artifact
111+
if-no-files-found: error
112+
113+
external-discovery-smoke:
114+
name: external-discovery-smoke (${{ matrix.provider }})
115+
runs-on: ubuntu-latest
116+
needs: [resolve-provider-matrix, build-services]
117+
timeout-minutes: 60
118+
strategy:
119+
fail-fast: false
120+
matrix:
121+
provider: ${{ fromJson(needs.resolve-provider-matrix.outputs.providers) }}
122+
steps:
123+
- uses: actions/checkout@v4
124+
125+
- name: Set up JDK 17
126+
uses: actions/setup-java@v4
127+
with:
128+
distribution: temurin
129+
java-version: 17
130+
131+
- name: Download runnable service artifacts
132+
uses: actions/download-artifact@v4
133+
with:
134+
name: apollo-discovery-jars
135+
path: /tmp/apollo-discovery-artifact
136+
137+
- name: Start external discovery provider
138+
run: |
139+
./e2e/discovery-smoke/scripts/provider.sh start "${{ matrix.provider }}" /tmp/discovery-provider.env
140+
cat /tmp/discovery-provider.env >> "${GITHUB_ENV}"
141+
142+
- name: Start Apollo config service
143+
env:
144+
SPRING_PROFILES_ACTIVE: github,${{ matrix.provider }}-discovery
145+
SPRING_DATASOURCE_URL: jdbc:h2:mem:apollo-configservice-db;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;BUILTIN_ALIAS_OVERRIDE=TRUE;DATABASE_TO_UPPER=FALSE
146+
SPRING_DATASOURCE_USERNAME: sa
147+
SPRING_DATASOURCE_PASSWORD: ""
148+
run: |
149+
java -jar /tmp/apollo-discovery-artifact/apollo-configservice.jar > /tmp/apollo-configservice-run.log 2>&1 &
150+
echo $! > /tmp/apollo-configservice.pid
151+
152+
- name: Start Apollo admin service
153+
env:
154+
SPRING_PROFILES_ACTIVE: github,${{ matrix.provider }}-discovery
155+
SPRING_DATASOURCE_URL: jdbc:h2:mem:apollo-adminservice-db;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;BUILTIN_ALIAS_OVERRIDE=TRUE;DATABASE_TO_UPPER=FALSE
156+
SPRING_DATASOURCE_USERNAME: sa
157+
SPRING_DATASOURCE_PASSWORD: ""
158+
run: |
159+
java -jar /tmp/apollo-discovery-artifact/apollo-adminservice.jar > /tmp/apollo-adminservice-run.log 2>&1 &
160+
echo $! > /tmp/apollo-adminservice.pid
161+
162+
- name: Run external discovery smoke
163+
env:
164+
DISCOVERY_PROVIDER: ${{ matrix.provider }}
165+
ARTIFACT_DIR: /tmp/external-discovery-smoke/${{ matrix.provider }}
166+
run: ./e2e/discovery-smoke/scripts/run-smoke.sh
167+
168+
- name: Capture discovery failure snapshots
169+
if: failure()
170+
env:
171+
DISCOVERY_PROVIDER: ${{ matrix.provider }}
172+
run: |
173+
mkdir -p "/tmp/external-discovery-smoke/${{ matrix.provider }}"
174+
curl -fsS http://127.0.0.1:8080/health \
175+
> "/tmp/external-discovery-smoke/${{ matrix.provider }}/configservice-health.json" 2>&1 || true
176+
curl -fsS http://127.0.0.1:8090/health \
177+
> "/tmp/external-discovery-smoke/${{ matrix.provider }}/adminservice-health.json" 2>&1 || true
178+
curl -fsS http://127.0.0.1:8080/services/admin \
179+
> "/tmp/external-discovery-smoke/${{ matrix.provider }}/configservice-services-admin.json" 2>&1 || true
180+
curl -fsS http://127.0.0.1:8080/services/config \
181+
> "/tmp/external-discovery-smoke/${{ matrix.provider }}/configservice-services-config.json" 2>&1 || true
182+
./e2e/discovery-smoke/scripts/provider.sh assert-service "${{ matrix.provider }}" "apollo-adminservice" \
183+
"/tmp/external-discovery-smoke/${{ matrix.provider }}/provider-apollo-adminservice.txt" >/dev/null 2>&1 || true
184+
./e2e/discovery-smoke/scripts/provider.sh assert-service "${{ matrix.provider }}" "apollo-configservice" \
185+
"/tmp/external-discovery-smoke/${{ matrix.provider }}/provider-apollo-configservice.txt" >/dev/null 2>&1 || true
186+
./e2e/discovery-smoke/scripts/provider.sh logs "${{ matrix.provider }}" \
187+
"/tmp/external-discovery-smoke/${{ matrix.provider }}/provider.log" >/dev/null 2>&1 || true
188+
189+
- name: Upload discovery smoke artifacts on failure
190+
if: failure()
191+
uses: actions/upload-artifact@v4
192+
with:
193+
name: external-discovery-smoke-artifacts-${{ matrix.provider }}
194+
path: |
195+
/tmp/apollo-configservice-run.log
196+
/tmp/apollo-adminservice-run.log
197+
/tmp/external-discovery-smoke/${{ matrix.provider }}
198+
if-no-files-found: warn
199+
200+
- name: Stop Apollo config service
201+
if: always()
202+
run: |
203+
if [ -f /tmp/apollo-configservice.pid ]; then
204+
kill "$(cat /tmp/apollo-configservice.pid)" || true
205+
fi
206+
207+
- name: Stop Apollo admin service
208+
if: always()
209+
run: |
210+
if [ -f /tmp/apollo-adminservice.pid ]; then
211+
kill "$(cat /tmp/apollo-adminservice.pid)" || true
212+
fi
213+
214+
- name: Stop external discovery provider
215+
if: always()
216+
run: ./e2e/discovery-smoke/scripts/provider.sh stop "${{ matrix.provider }}"

.github/workflows/portal-login-e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ on:
2323
- 'apollo-portal/**'
2424
- 'apollo-assembly/**'
2525
- 'e2e/portal-e2e/**'
26+
- 'e2e/scripts/**'
2627
- '.github/workflows/portal-login-e2e.yml'
2728

2829
jobs:

.github/workflows/portal-ui-e2e.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ on:
2323
- 'apollo-portal/**'
2424
- 'apollo-assembly/**'
2525
- 'e2e/portal-e2e/**'
26+
- 'e2e/scripts/**'
2627
- 'scripts/sql/**'
2728
- '.github/workflows/portal-ui-e2e.yml'
2829

@@ -82,6 +83,9 @@ jobs:
8283
echo $! > /tmp/apollo-assembly.pid
8384
8485
- name: Wait for Apollo readiness
86+
env:
87+
PORTAL_USERNAME: apollo
88+
PORTAL_PASSWORD: admin
8589
run: ./e2e/portal-e2e/scripts/wait-for-ready.sh
8690

8791
- name: Run Playwright UI tests

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Apollo 3.0.0
88
* [Fix: include super admin in hasAnyPermission semantics](https://github.com/apolloconfig/apollo/pull/5568)
99
* [Change: official Config/Admin packages now default to database discovery; upgraded Eureka deployments should explicitly keep the `github` profile to preserve legacy behavior](https://github.com/apolloconfig/apollo/pull/5580)
1010
* [Refactor: extract config constants and methods in BizConfig, PortalConfig, and RefreshableConfig](https://github.com/apolloconfig/apollo/pull/5583)
11+
* [Change: migrate Apollo server baseline to Spring Boot 4.0.x, align Spring Cloud discovery integrations, and add external discovery smoke workflow](https://github.com/apolloconfig/apollo/pull/5585)
1112

1213
------------------
1314
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/18?closed=1)

apollo-adminservice/pom.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,8 @@
161161
<id>nacos-discovery</id>
162162
<dependencies>
163163
<dependency>
164-
<groupId>com.alibaba.boot</groupId>
165-
<artifactId>nacos-discovery-spring-boot-starter</artifactId>
166-
</dependency>
167-
<dependency>
168-
<groupId>com.alibaba</groupId>
169-
<artifactId>fastjson</artifactId>
164+
<groupId>com.alibaba.cloud</groupId>
165+
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
170166
</dependency>
171167
</dependencies>
172168
</profile>

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceApplication.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818

1919
import com.ctrip.framework.apollo.biz.ApolloBizConfig;
2020
import com.ctrip.framework.apollo.common.ApolloCommonConfig;
21-
2221
import org.springframework.boot.SpringApplication;
2322
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
24-
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;
25-
import org.springframework.boot.autoconfigure.session.SessionAutoConfiguration;
23+
import org.springframework.boot.security.autoconfigure.UserDetailsServiceAutoConfiguration;
2624
import org.springframework.context.annotation.ComponentScan;
2725
import org.springframework.context.annotation.Configuration;
2826
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@@ -32,8 +30,7 @@
3230
@EnableAspectJAutoProxy
3331
@Configuration
3432
@PropertySource(value = {"classpath:adminservice.properties"})
35-
@EnableAutoConfiguration(
36-
exclude = {UserDetailsServiceAutoConfiguration.class, SessionAutoConfiguration.class})
33+
@EnableAutoConfiguration(exclude = UserDetailsServiceAutoConfiguration.class)
3734
@EnableTransactionManagement
3835
@ComponentScan(basePackageClasses = {ApolloCommonConfig.class, ApolloBizConfig.class,
3936
AdminServiceApplication.class})

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/AdminServiceHealthIndicator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package com.ctrip.framework.apollo.adminservice;
1818

1919
import com.ctrip.framework.apollo.biz.service.AppService;
20-
import org.springframework.boot.actuate.health.Health;
21-
import org.springframework.boot.actuate.health.HealthIndicator;
20+
import org.springframework.boot.health.contributor.Health;
21+
import org.springframework.boot.health.contributor.HealthIndicator;
2222
import org.springframework.data.domain.PageRequest;
2323
import org.springframework.stereotype.Component;
2424

apollo-adminservice/src/main/resources/application-consul-discovery.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ eureka.client.enabled=false
1717
#consul enabled
1818
spring.cloud.consul.enabled=true
1919
spring.cloud.consul.discovery.enabled=true
20+
spring.cloud.consul.discovery.service-name=apollo-adminservice
21+
spring.cloud.consul.discovery.register=true
2022
spring.cloud.consul.service-registry.enabled=true
23+
spring.cloud.consul.service-registry.auto-registration.enabled=true
2124
spring.cloud.consul.discovery.heartbeat.enabled=true
2225
spring.cloud.consul.discovery.instance-id=apollo-adminservice

apollo-adminservice/src/main/resources/application-nacos-discovery.properties

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
# limitations under the License.
1515
#
1616
eureka.client.enabled=false
17-
spring.cloud.discovery.enabled=false
17+
spring.cloud.discovery.enabled=true
1818
#nacos enabled
19-
nacos.discovery.register.enabled=true
20-
nacos.discovery.auto-register=true
21-
nacos.discovery.register.service-name=apollo-adminservice
19+
spring.cloud.nacos.discovery.register-enabled=true
20+
spring.cloud.nacos.discovery.service=apollo-adminservice

apollo-adminservice/src/main/resources/application-zookeeper-discovery.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ eureka.client.enabled=false
1919
spring.cloud.zookeeper.enabled=true
2020
spring.cloud.zookeeper.discovery.enabled=true
2121
spring.cloud.zookeeper.discovery.register=true
22-
spring.cloud.zookeeper.discovery.instance-id=${spring.cloud.client.ip-address}:${server.port}
22+
spring.cloud.zookeeper.discovery.instance-id=${spring.cloud.client.ip-address}:${server.port}

0 commit comments

Comments
 (0)