Skip to content

Commit 821c855

Browse files
Aniloplenobodyiam
andauthored
feat: use can change spring.profiles.active's value without rebuild project (#4616)
* refactor: move spring.profiles.active to application.properties * fix: h2 test error when spring.jpa.properties.hibernate.globally_quoted_identifiers=true * fix(adminservice): test fail h2 test error when globally_quoted_identifiers = true * fix(configservice): test fail h2 test error when globally_quoted_identifiers=true * fix(portal): test fail h2 test error when globally_quoted_identifiers=true * fix: ${apollo_profile} * fix: license * feat: user only need to uncomment spring.profiles.active * test: fix * refactor: rename back to application.properties in src/test/resources * fix: applicatioin.properties -> applicatioin.yaml forbid cover config * test: add config DB_CLOSE_DELAY=-1 * test: fix config apolloconfigdb -> apolloportaldb * refactor: remove @TestPropertySource("classpath:" + "application.properties") * Update distributed-deployment-guide.md * fix: delete kubernetes and nacos discovery in application.properties * Update docs/zh/deployment/distributed-deployment-guide.md Co-authored-by: Jason Song <[email protected]> * Update docs/zh/deployment/distributed-deployment-guide.md Co-authored-by: Jason Song <[email protected]> * Update docs/zh/deployment/distributed-deployment-guide.md Co-authored-by: Jason Song <[email protected]> * Apply suggestions from code review Co-authored-by: Jason Song <[email protected]> * move up `启用外部xxxxxx` * docs: Replace built-in eureka with another service registry * Update CHANGES.md Co-authored-by: Jason Song <[email protected]>
1 parent 4604e30 commit 821c855

File tree

15 files changed

+477
-175
lines changed

15 files changed

+477
-175
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Apollo 2.1.0
3636
* [feat: support use database as a registry](https://github.com/apolloconfig/apollo/pull/4595)
3737
* [fix doc bug](https://github.com/apolloconfig/apollo/pull/4579)
3838
* [fix Grayscale release Item Value length limit can not be synchronized with its main version](https://github.com/apolloconfig/apollo/pull/4622)
39+
* [feat: use can change spring.profiles.active's value without rebuild project](https://github.com/apolloconfig/apollo/pull/4616)
3940

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

apollo-adminservice/src/assembly/assembly-descriptor.xml

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<outputDirectory>/config</outputDirectory>
5757
<includes>
5858
<include>application-github.properties</include>
59+
<include>application.properties</include>
5960
</includes>
6061
</fileSet>
6162
<!--artifact -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Copyright 2022 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+
# You may uncomment the following config to activate different spring profiles
18+
#spring.profiles.active=github,consul-discovery
19+
#spring.profiles.active=github,zookeeper-discovery
20+
#spring.profiles.active=github,custom-defined-discovery
21+
#spring.profiles.active=github,database-discovery

apollo-adminservice/src/test/resources/application.properties

+10-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,20 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
spring.cloud.consul.enabled=false
17+
spring.cloud.zookeeper.enabled=false
18+
spring.cloud.discovery.enabled=false
19+
1620
spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
21+
1722
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
23+
spring.jpa.hibernate.globally_quoted_identifiers=false
24+
spring.jpa.properties.hibernate.globally_quoted_identifiers=false
1825
spring.jpa.properties.hibernate.show_sql=false
1926
spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor
27+
spring.jpa.defer-datasource-initialization=true
28+
2029
spring.h2.console.enabled = true
2130
spring.h2.console.settings.web-allow-others=true
31+
2232
spring.main.allow-bean-definition-overriding=true
23-
spring.cloud.consul.enabled=false
24-
spring.cloud.zookeeper.enabled=false
25-
spring.jpa.defer-datasource-initialization=true

apollo-assembly/src/test/resources/application.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE
16+
spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
1717
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
1818
spring.jpa.properties.hibernate.show_sql=false
1919
spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor

apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
@RunWith(SpringJUnit4ClassRunner.class)
2727
@Rollback
2828
@Transactional
29-
@SpringBootTest(classes = BizTestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT
30-
, properties = {"spring.cloud.discovery.enabled=false"})
29+
@SpringBootTest(
30+
classes = BizTestConfiguration.class,
31+
webEnvironment = WebEnvironment.RANDOM_PORT
32+
)
3133
public abstract class AbstractIntegrationTest {
3234

3335
}

apollo-biz/src/test/resources/application.properties

+11-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE
16+
spring.cloud.consul.enabled=false
17+
spring.cloud.zookeeper.enabled=false
18+
spring.cloud.discovery.enabled=false
19+
20+
spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
21+
1722
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
23+
spring.jpa.hibernate.globally_quoted_identifiers=false
24+
spring.jpa.properties.hibernate.globally_quoted_identifiers=false
1825
spring.jpa.properties.hibernate.show_sql=false
1926
spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor
27+
spring.jpa.defer-datasource-initialization=true
28+
2029
spring.h2.console.enabled = true
21-
spring.h2.console.settings.web-allow-others=true
22-
spring.cloud.consul.enabled=false
23-
spring.cloud.zookeeper.enabled=false
24-
spring.jpa.defer-datasource-initialization=true
30+
spring.h2.console.settings.web-allow-others=true

apollo-common/src/main/resources/application.properties

-40
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#
2+
# Copyright 2022 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+
spring:
18+
jpa:
19+
properties:
20+
hibernate:
21+
globally_quoted_identifiers: 'true'
22+
hibernate:
23+
globally_quoted_identifiers: 'true'
24+
# Naming strategy
25+
naming:
26+
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
27+
info:
28+
# Project information
29+
git:
30+
location: classpath:apollo-git.properties
31+
mvc:
32+
converters:
33+
preferred-json-mapper: gson
34+
# DataSource
35+
datasource:
36+
hikari:
37+
connectionInitSql: set names utf8mb4
38+
39+
# Tomcat configuration
40+
server:
41+
tomcat:
42+
accept-count: '5000'
43+
# Increase tomcat header size for longer GET query parameter, should be n * 1024
44+
max-http-header-size: '10240'
45+
46+
# Spring Boot 2.x
47+
management:
48+
endpoints:
49+
web:
50+
exposure:
51+
include: info,health,metrics,prometheus
52+
base-path: /
53+
logging:
54+
logback:
55+
rollingpolicy:
56+
max-history: '10'
57+
max-file-size: 50MB

apollo-configservice/src/assembly/assembly-descriptor.xml

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<outputDirectory>/config</outputDirectory>
5757
<includes>
5858
<include>application-github.properties</include>
59+
<include>application.properties</include>
5960
</includes>
6061
</fileSet>
6162
<!--artifact -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Copyright 2022 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+
# You may uncomment the following config to activate different spring profiles
18+
#spring.profiles.active=github,consul-discovery
19+
#spring.profiles.active=github,zookeeper-discovery
20+
#spring.profiles.active=github,custom-defined-discovery
21+
#spring.profiles.active=github,database-discovery

apollo-configservice/src/test/resources/application.properties

+9-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
spring.cloud.consul.enabled=false
17+
spring.cloud.zookeeper.enabled=false
18+
1619
spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
20+
1721
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
22+
spring.jpa.hibernate.globally_quoted_identifiers=false
23+
spring.jpa.properties.hibernate.globally_quoted_identifiers=false
1824
spring.jpa.properties.hibernate.show_sql=false
1925
spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor
26+
spring.jpa.defer-datasource-initialization=true
27+
2028
spring.h2.console.enabled = true
2129
spring.h2.console.settings.web-allow-others=true
22-
spring.cloud.consul.enabled=false
23-
spring.cloud.zookeeper.enabled=false
30+
2431
spring.main.allow-bean-definition-overriding=true
25-
spring.jpa.defer-datasource-initialization=true
2632

2733
# for ReleaseMessageScanner test
2834
apollo.message-scan.interval=100

apollo-portal/src/test/resources/application.properties

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,21 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
spring.session.store-type=none
16+
spring.cloud.consul.enabled=false
17+
spring.cloud.zookeeper.enabled=false
18+
spring.cloud.discovery.enabled=false
19+
1720
spring.datasource.url = jdbc:h2:mem:~/apolloportaldb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
21+
1822
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
23+
spring.jpa.hibernate.globally_quoted_identifiers=false
24+
spring.jpa.properties.hibernate.globally_quoted_identifiers=false
1925
spring.jpa.properties.hibernate.show_sql=false
2026
spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor
27+
spring.jpa.defer-datasource-initialization=true
28+
2129
spring.h2.console.enabled = true
2230
spring.h2.console.settings.web-allow-others=true
31+
32+
spring.session.store-type=none
2333
spring.main.allow-bean-definition-overriding=true

0 commit comments

Comments
 (0)