diff --git a/pom.xml b/pom.xml
index 7fa1a97..6146220 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,6 +66,11 @@
org.springframework.boot
spring-boot-autoconfigure
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
org.springframework.boot
spring-boot-starter
diff --git a/src/main/java/com/ossez/wechat/demo/config/WxMpAutoConfiguration.java b/src/main/java/com/ossez/wechat/demo/config/WxMpAutoConfiguration.java
index b3f2090..0f82eb8 100644
--- a/src/main/java/com/ossez/wechat/demo/config/WxMpAutoConfiguration.java
+++ b/src/main/java/com/ossez/wechat/demo/config/WxMpAutoConfiguration.java
@@ -1,6 +1,6 @@
package com.ossez.wechat.demo.config;
-import com.ossez.wechat.demo.properties.WxMpProperties;
+import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@@ -11,7 +11,7 @@ import org.springframework.context.annotation.Import;
* @author someone
*/
@Configuration
-@EnableConfigurationProperties(WxMpProperties.class)
+@EnableConfigurationProperties(WeChatOfficialAccountProperties.class)
@Import({ WxMpStorageAutoConfiguration.class, WxMpServiceAutoConfiguration.class })
public class WxMpAutoConfiguration {
}
diff --git a/src/main/java/com/ossez/wechat/demo/config/WxMpServiceAutoConfiguration.java b/src/main/java/com/ossez/wechat/demo/config/WxMpServiceAutoConfiguration.java
index 9853b54..7204d7e 100644
--- a/src/main/java/com/ossez/wechat/demo/config/WxMpServiceAutoConfiguration.java
+++ b/src/main/java/com/ossez/wechat/demo/config/WxMpServiceAutoConfiguration.java
@@ -1,7 +1,7 @@
package com.ossez.wechat.demo.config;
import com.ossez.wechat.demo.enums.HttpClientType;
-import com.ossez.wechat.demo.properties.WxMpProperties;
+import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
import com.ossez.wechat.oa.api.WxMpService;
import com.ossez.wechat.oa.api.impl.WxMpServiceHttpClientImpl;
import com.ossez.wechat.oa.api.impl.WxMpServiceImpl;
@@ -22,7 +22,7 @@ public class WxMpServiceAutoConfiguration {
@Bean
@ConditionalOnMissingBean
- public WxMpService wxMpService(WxMpConfigStorage configStorage, WxMpProperties wxMpProperties) {
+ public WxMpService wxMpService(WxMpConfigStorage configStorage, WeChatOfficialAccountProperties wxMpProperties) {
HttpClientType httpClientType = wxMpProperties.getConfigStorage().getHttpClientType();
WxMpService wxMpService;
switch (httpClientType) {
diff --git a/src/main/java/com/ossez/wechat/demo/config/WxMpStorageAutoConfiguration.java b/src/main/java/com/ossez/wechat/demo/config/WxMpStorageAutoConfiguration.java
index e78b09b..8461961 100644
--- a/src/main/java/com/ossez/wechat/demo/config/WxMpStorageAutoConfiguration.java
+++ b/src/main/java/com/ossez/wechat/demo/config/WxMpStorageAutoConfiguration.java
@@ -2,7 +2,7 @@ package com.ossez.wechat.demo.config;
import com.ossez.wechat.demo.enums.StorageType;
import com.ossez.wechat.demo.properties.RedisProperties;
-import com.ossez.wechat.demo.properties.WxMpProperties;
+import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -37,7 +37,7 @@ import java.util.Set;
public class WxMpStorageAutoConfiguration {
private final ApplicationContext applicationContext;
- private final WxMpProperties wxMpProperties;
+ private final WeChatOfficialAccountProperties wxMpProperties;
@Bean
@ConditionalOnMissingBean(WxMpConfigStorage.class)
@@ -115,8 +115,8 @@ public class WxMpStorageAutoConfiguration {
}
private void setWxMpInfo(WxMpDefaultConfigImpl config) {
- WxMpProperties properties = wxMpProperties;
- WxMpProperties.ConfigStorage configStorageProperties = properties.getConfigStorage();
+ WeChatOfficialAccountProperties properties = wxMpProperties;
+ WeChatOfficialAccountProperties.ConfigStorage configStorageProperties = properties.getConfigStorage();
config.setAppId(properties.getAppId());
config.setSecret(properties.getSecret());
config.setToken(properties.getToken());
diff --git a/src/main/java/com/ossez/wechat/demo/properties/WxMpProperties.java b/src/main/java/com/ossez/wechat/demo/properties/WeChatOfficialAccountProperties.java
similarity index 91%
rename from src/main/java/com/ossez/wechat/demo/properties/WxMpProperties.java
rename to src/main/java/com/ossez/wechat/demo/properties/WeChatOfficialAccountProperties.java
index 7c3fa72..5bcd3ba 100644
--- a/src/main/java/com/ossez/wechat/demo/properties/WxMpProperties.java
+++ b/src/main/java/com/ossez/wechat/demo/properties/WeChatOfficialAccountProperties.java
@@ -9,7 +9,6 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
import java.io.Serializable;
import static com.ossez.wechat.demo.enums.StorageType.Memory;
-import static com.ossez.wechat.demo.properties.WxMpProperties.PREFIX;
/**
* 微信接入相关配置属性.
@@ -17,9 +16,8 @@ import static com.ossez.wechat.demo.properties.WxMpProperties.PREFIX;
* @author someone
*/
@Data
-@ConfigurationProperties(PREFIX)
-public class WxMpProperties {
- public static final String PREFIX = "wx.mp";
+@ConfigurationProperties(prefix = "wechat.official-account")
+public class WeChatOfficialAccountProperties {
/**
* 设置微信公众号的appid.
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 3dbd9a0..9b515bd 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -35,8 +35,8 @@ spring.datasource.hikari.data-source-properties.elideSetAutoCommits=true
spring.datasource.hikari.data-source-properties.maintainTimeStats=false
# KEY
-wx.mp.appId = appId
-wx.mp.secret = @secret
-wx.mp.token = @token
-wx.mp.aesKey = @aesKey
+wechat.official-account.app-id = appId
+wechat.official-account.secret = secret
+wechat.official-account.token = token
+wechat.official-account.aes-key = aesKey