mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-18 14:28:08 +08:00
properties优化
properties优化
This commit is contained in:
@@ -9,6 +9,7 @@ import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
||||
import org.maxkey.authn.support.rememberme.InMemoryRemeberMeService;
|
||||
import org.maxkey.authn.support.rememberme.JdbcRemeberMeService;
|
||||
import org.maxkey.authn.support.rememberme.RedisRemeberMeService;
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.maxkey.crypto.keystore.KeyStoreLoader;
|
||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
@@ -31,8 +32,8 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:/application.properties")
|
||||
@PropertySource("classpath:/config/applicationConfig.properties")
|
||||
@PropertySource(ConstantsProperties.applicationPropertySource)
|
||||
@PropertySource(ConstantsProperties.maxKeyPropertySource)
|
||||
public class ApplicationAutoConfiguration implements InitializingBean {
|
||||
private static final Logger _logger =
|
||||
LoggerFactory.getLogger(ApplicationAutoConfiguration.class);
|
||||
@@ -53,8 +54,11 @@ public class ApplicationAutoConfiguration implements InitializingBean {
|
||||
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer()
|
||||
throws IOException {
|
||||
ClassPathResource classPathResource1 =
|
||||
new ClassPathResource("/config/applicationConfig.properties");
|
||||
ClassPathResource classPathResource2 = new ClassPathResource("/application.properties");
|
||||
new ClassPathResource(ConstantsProperties.classPathResource(
|
||||
ConstantsProperties.applicationPropertySource));
|
||||
ClassPathResource classPathResource2 =
|
||||
new ClassPathResource(ConstantsProperties.classPathResource(
|
||||
ConstantsProperties.maxKeyPropertySource));
|
||||
|
||||
PropertySourcesPlaceholderConfigurer configurer =
|
||||
new PropertySourcesPlaceholderConfigurer();
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import org.maxkey.authn.support.jwt.JwtLoginService;
|
||||
import org.maxkey.config.oidc.OIDCProviderMetadataDetails;
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.maxkey.crypto.jose.keystore.JWKSetKeyStore;
|
||||
import org.maxkey.crypto.jwt.encryption.service.impl.DefaultJwtEncryptionAndDecryptionService;
|
||||
import org.maxkey.crypto.jwt.signer.service.impl.DefaultJwtSigningAndValidationService;
|
||||
@@ -21,8 +22,8 @@ import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:/application.properties")
|
||||
@PropertySource("classpath:/config/applicationConfig.properties")
|
||||
@PropertySource(ConstantsProperties.applicationPropertySource)
|
||||
@PropertySource(ConstantsProperties.maxKeyPropertySource)
|
||||
public class JwtAuthnAutoConfiguration implements InitializingBean {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(JwtAuthnAutoConfiguration.class);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.google.code.kaptcha.util.Config;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -25,7 +26,8 @@ public class KaptchaAutoConfiguration implements InitializingBean {
|
||||
*/
|
||||
@Bean (name = "captchaProducer")
|
||||
public Producer captchaProducer() throws IOException {
|
||||
Resource resource = new ClassPathResource("/kaptcha.properties");
|
||||
Resource resource = new ClassPathResource(
|
||||
ConstantsProperties.classPathResource(ConstantsProperties.kaptchaPropertySource));
|
||||
_logger.debug("Kaptcha config file " + resource.getURL());
|
||||
DefaultKaptcha kaptcha = new DefaultKaptcha();
|
||||
Properties properties = new Properties();
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.maxkey.autoconfigure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -28,8 +30,8 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
|
||||
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:/application.properties")
|
||||
@PropertySource("classpath:/config/applicationConfig.properties")
|
||||
@PropertySource(ConstantsProperties.applicationPropertySource)
|
||||
@PropertySource(ConstantsProperties.maxKeyPropertySource)
|
||||
public class MvcAutoConfiguration implements InitializingBean {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(MvcAutoConfiguration.class);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.maxkey.autoconfigure;
|
||||
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -11,7 +12,7 @@ import org.springframework.context.annotation.PropertySource;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:/application.properties")
|
||||
@PropertySource(ConstantsProperties.applicationPropertySource)
|
||||
public class RedisAutoConfiguration implements InitializingBean {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(RedisAutoConfiguration.class);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.maxkey.config;
|
||||
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -18,7 +19,8 @@ import org.springframework.stereotype.Component;
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@PropertySource("classpath:/config/applicationConfig.properties")
|
||||
@PropertySource(ConstantsProperties.maxKeyPropertySource)
|
||||
@PropertySource(ConstantsProperties.applicationPropertySource)
|
||||
public class ApplicationConfig {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(ApplicationConfig.class);
|
||||
|
||||
@@ -47,6 +49,16 @@ public class ApplicationConfig {
|
||||
@Value("${config.server.management.uri}")
|
||||
String managementUri;
|
||||
|
||||
@Value("${server.port:8080}")
|
||||
private int port;
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
/*
|
||||
* //is enable whiteList for ipAddress filter boolean whiteList;
|
||||
*
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.maxkey.config;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
@@ -12,7 +14,7 @@ import org.springframework.context.annotation.PropertySource;
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
@PropertySource("classpath:/application.properties")
|
||||
@PropertySource(ConstantsProperties.applicationPropertySource)
|
||||
public class CharacterEncodingConfig {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package org.maxkey.config;
|
||||
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:/application.properties")
|
||||
@PropertySource(ConstantsProperties.applicationPropertySource)
|
||||
public class EmailConfig {
|
||||
|
||||
@Value("${spring.mail.username}")
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package org.maxkey.config;
|
||||
|
||||
import org.maxkey.constants.ConstantsProperties;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:/config/applicationConfig.properties")
|
||||
@PropertySource(ConstantsProperties.maxKeyPropertySource)
|
||||
public class LoginConfig {
|
||||
@Value("${config.login.captcha}")
|
||||
boolean captcha;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.maxkey.constants;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class ConstantsProperties {
|
||||
|
||||
public static final String applicationPropertySource =
|
||||
"classpath:/application.properties";
|
||||
|
||||
public static final String maxKeyPropertySource =
|
||||
"classpath:/maxkey.properties";
|
||||
|
||||
public static final String kaptchaPropertySource =
|
||||
"classpath:/kaptcha.properties";
|
||||
|
||||
public static String classPathResource(String propertySource) {
|
||||
return propertySource.replaceAll("classpath:","");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classPathResourceTest() {
|
||||
System.out.println(classPathResource(maxKeyPropertySource));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user