Skip to content

Commit d64134e

Browse files
committed
🛠️ [chore] Centralize Spring Boot configuration property prefixes
- Introduced `SpringBootConfigurationPropertiesPrefixes` for unified configuration prefix management. - Refactored multiple modules to use the centralized constants (`@ConfigurationProperties`) replacing hardcoded prefixes. - Enhanced maintainability and reduced redundancy across shared, security, OSS, pay, PSDK, depend, and testtoolkit modules.
1 parent 7f0d73d commit d64134e

20 files changed

Lines changed: 202 additions & 42 deletions

File tree

depend/depend-paho/src/main/kotlin/io/github/truenine/composeserver/depend/paho/properties/SingleMqttProperties.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package io.github.truenine.composeserver.depend.paho.properties
22

3+
import io.github.truenine.composeserver.consts.SpringBootConfigurationPropertiesPrefixes
34
import java.util.*
45
import org.springframework.boot.context.properties.ConfigurationProperties
56

6-
private const val PREFIX = "compose.depend.paho"
7-
8-
@ConfigurationProperties(prefix = "$PREFIX.client")
7+
@ConfigurationProperties(prefix = SpringBootConfigurationPropertiesPrefixes.DEPEND_PAHO_CLIENT)
98
data class SingleMqttProperties(
109
/** schema = tcp:// */
1110
var url: String? = null,

depend/depend-servlet/src/main/kotlin/io/github/truenine/composeserver/depend/servlet/properties/ServletWebApplicationProperties.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package io.github.truenine.composeserver.depend.servlet.properties
22

3+
import io.github.truenine.composeserver.consts.SpringBootConfigurationPropertiesPrefixes
34
import kotlin.reflect.KClass
45
import org.springframework.boot.context.properties.ConfigurationProperties
56
import org.springframework.http.converter.StringHttpMessageConverter
67

7-
private const val PREFIX = "compose.depend.servlet"
8-
98
/**
109
* spring web mvc http servlet 配置属性
1110
*
1211
* @author TrueNine
1312
* @since 2023-02-20
1413
*/
15-
@ConfigurationProperties(prefix = PREFIX)
14+
@ConfigurationProperties(prefix = SpringBootConfigurationPropertiesPrefixes.DEPEND_SERVLET)
1615
data class ServletWebApplicationProperties(
1716
var allowConverters: MutableList<String> = mutableListOf("getDocumentation", "swaggerResources", "openapiJson"),
1817
var allowConverterClasses: MutableList<KClass<*>> = mutableListOf(StringHttpMessageConverter::class),

depend/depend-springdoc-openapi/src/main/kotlin/io/github/truenine/composeserver/depend/springdocopenapi/properties/SpringdocOpenApiProperties.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package io.github.truenine.composeserver.depend.springdocopenapi.properties
22

3+
import io.github.truenine.composeserver.consts.SpringBootConfigurationPropertiesPrefixes
34
import org.springframework.boot.context.properties.ConfigurationProperties
45
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding
56
import org.springframework.boot.context.properties.NestedConfigurationProperty
67

7-
private const val PREFIX = "compose.depend.springdoc-open-api"
8-
98
@ConfigurationPropertiesBinding
10-
@ConfigurationProperties(prefix = PREFIX, ignoreUnknownFields = true)
9+
@ConfigurationProperties(prefix = SpringBootConfigurationPropertiesPrefixes.DEPEND_SPRINGDOC_OPENAPI, ignoreUnknownFields = true)
1110
data class SpringdocOpenApiProperties(
1211
/** 扫描的包 */
1312
var scanPackages: MutableList<String> = mutableListOf(),

oss/oss-minio/src/main/kotlin/io/github/truenine/composeserver/oss/minio/autoconfig/MinioAutoConfiguration.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.truenine.composeserver.oss.minio.autoconfig
22

3+
import io.github.truenine.composeserver.consts.SpringBootConfigurationPropertiesPrefixes
34
import io.github.truenine.composeserver.logger
45
import io.github.truenine.composeserver.oss.ObjectStorageService
56
import io.github.truenine.composeserver.oss.minio.MinioObjectStorageService
@@ -23,7 +24,7 @@ import org.springframework.context.annotation.Configuration
2324
*/
2425
@Configuration
2526
@ConditionalOnClass(MinioClient::class)
26-
@ConditionalOnProperty(prefix = "compose.oss", name = ["provider"], havingValue = "minio")
27+
@ConditionalOnProperty(prefix = SpringBootConfigurationPropertiesPrefixes.OSS, name = ["provider"], havingValue = "minio")
2728
@EnableConfigurationProperties(MinioProperties::class, OssProperties::class)
2829
class MinioAutoConfiguration {
2930

oss/oss-minio/src/main/kotlin/io/github/truenine/composeserver/oss/minio/properties/MinioProperties.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package io.github.truenine.composeserver.oss.minio.properties
22

3+
import io.github.truenine.composeserver.consts.SpringBootConfigurationPropertiesPrefixes
34
import java.time.Duration
45
import org.springframework.boot.context.properties.ConfigurationProperties
56

6-
private const val PREFIX = "compose.oss.minio"
7-
87
/**
98
* Modern MinIO configuration properties
109
*
@@ -22,7 +21,7 @@ private const val PREFIX = "compose.oss.minio"
2221
* @author TrueNine
2322
* @since 2025-01-04
2423
*/
25-
@ConfigurationProperties(prefix = PREFIX)
24+
@ConfigurationProperties(prefix = SpringBootConfigurationPropertiesPrefixes.OSS_MINIO)
2625
data class MinioProperties(
2726
var endpoint: String = "127.0.0.1",
2827
var port: Int = 9000,

oss/oss-shared/src/main/kotlin/io/github/truenine/composeserver/oss/properties/OssProperties.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package io.github.truenine.composeserver.oss.properties
22

3+
import io.github.truenine.composeserver.consts.SpringBootConfigurationPropertiesPrefixes
34
import java.time.Duration
45
import org.springframework.boot.context.properties.ConfigurationProperties
56

6-
private const val PREFIX = "compose.oss"
7-
87
/**
98
* Modern OSS configuration properties
109
*
@@ -28,7 +27,7 @@ private const val PREFIX = "compose.oss"
2827
* @author TrueNine
2928
* @since 2025-01-04
3029
*/
31-
@ConfigurationProperties(prefix = PREFIX)
30+
@ConfigurationProperties(prefix = SpringBootConfigurationPropertiesPrefixes.OSS)
3231
data class OssProperties(
3332
/** OSS provider type (minio, volcengine-tos, aliyun-oss, etc.) */
3433
var provider: String? = null,

oss/oss-volcengine-tos/src/main/kotlin/io/github/truenine/composeserver/oss/volcengine/autoconfig/VolcengineTosAutoConfiguration.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.volcengine.tos.TOSV2
55
import com.volcengine.tos.TOSV2ClientBuilder
66
import com.volcengine.tos.auth.StaticCredentials
77
import com.volcengine.tos.transport.TransportConfig
8+
import io.github.truenine.composeserver.consts.SpringBootConfigurationPropertiesPrefixes
89
import io.github.truenine.composeserver.logger
910
import io.github.truenine.composeserver.oss.ObjectStorageService
1011
import io.github.truenine.composeserver.oss.properties.OssProperties
@@ -32,7 +33,7 @@ import org.springframework.context.annotation.Configuration
3233
*/
3334
@Configuration
3435
@ConditionalOnClass(TOSV2::class)
35-
@ConditionalOnProperty(prefix = "compose.oss", name = ["provider"], havingValue = "volcengine-tos")
36+
@ConditionalOnProperty(prefix = SpringBootConfigurationPropertiesPrefixes.OSS, name = ["provider"], havingValue = "volcengine-tos")
3637
@EnableConfigurationProperties(VolcengineTosProperties::class, OssProperties::class)
3738
class VolcengineTosAutoConfiguration {
3839

oss/oss-volcengine-tos/src/main/kotlin/io/github/truenine/composeserver/oss/volcengine/properties/VolcengineTosProperties.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package io.github.truenine.composeserver.oss.volcengine.properties
22

3+
import io.github.truenine.composeserver.consts.SpringBootConfigurationPropertiesPrefixes
34
import org.springframework.boot.context.properties.ConfigurationProperties
45

5-
private const val PREFIX = "compose.oss.volcengine-tos"
6-
76
/**
87
* Volcengine TOS configuration properties with optimized defaults
98
*
@@ -41,7 +40,7 @@ private const val PREFIX = "compose.oss.volcengine-tos"
4140
* @author TrueNine
4241
* @since 2025-08-04
4342
*/
44-
@ConfigurationProperties(prefix = PREFIX)
43+
@ConfigurationProperties(prefix = SpringBootConfigurationPropertiesPrefixes.OSS_VOLCENGINE_TOS)
4544
data class VolcengineTosProperties(
4645
/** Service endpoint URL */
4746
var endpoint: String? = null,

pay/pay-wechat/src/main/kotlin/io/github/truenine/composeserver/pay/wechat/properties/WeChatPayProperties.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package io.github.truenine.composeserver.pay.wechat.properties
22

3+
import io.github.truenine.composeserver.consts.SpringBootConfigurationPropertiesPrefixes
34
import org.springframework.boot.context.properties.ConfigurationProperties
45

5-
private const val PREFIX = "compose.pay"
6-
76
/**
87
* # 微信单支付 js API 配置 <br></br>
98
* [微信支付文档](https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_1.shtml)
109
*
1110
* @author shanghua
1211
* @since 2023-05-05
1312
*/
14-
@ConfigurationProperties(prefix = "$PREFIX.wechat", ignoreUnknownFields = true)
13+
@ConfigurationProperties(prefix = SpringBootConfigurationPropertiesPrefixes.PAY_WECHAT, ignoreUnknownFields = true)
1514
data class WeChatPayProperties(
1615
/** 开启 单配置支付 */
1716
var enableSingle: Boolean = false,

psdk/psdk-wxpa/src/main/kotlin/io/github/truenine/composeserver/psdk/wxpa/autoconfig/WxpaAutoConfiguration.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.truenine.composeserver.psdk.wxpa.autoconfig
22

3+
import io.github.truenine.composeserver.consts.SpringBootConfigurationPropertiesPrefixes
34
import io.github.truenine.composeserver.logger
45
import io.github.truenine.composeserver.psdk.wxpa.api.IWxpaWebClient
56
import io.github.truenine.composeserver.psdk.wxpa.core.WxpaSignatureGenerator
@@ -62,7 +63,12 @@ class WxpaAutoConfiguration {
6263
}
6364

6465
@Bean
65-
@ConditionalOnProperty(prefix = "compose.psdk.wxpa.wxpa", name = ["enable-auto-refresh"], havingValue = "true", matchIfMissing = true)
66+
@ConditionalOnProperty(
67+
prefix = "${SpringBootConfigurationPropertiesPrefixes.PSDK_WXPA}.wxpa",
68+
name = ["enable-auto-refresh"],
69+
havingValue = "true",
70+
matchIfMissing = true,
71+
)
6672
fun wxpaTokenEventManager(tokenManager: WxpaTokenManager, properties: WxpaProperties): WxpaTokenEventManager {
6773
log.info("Creating WxpaTokenEventManager")
6874
return WxpaTokenEventManager(tokenManager, properties)

0 commit comments

Comments
 (0)