|
@@ -3,14 +3,6 @@ package com.uas.ps.message;
|
|
|
import com.uas.account.web.AccountConfigurer;
|
|
import com.uas.account.web.AccountConfigurer;
|
|
|
import com.uas.ps.core.util.ContextUtils;
|
|
import com.uas.ps.core.util.ContextUtils;
|
|
|
import com.uas.sso.web.SSOConfigurer;
|
|
import com.uas.sso.web.SSOConfigurer;
|
|
|
-import java.io.File;
|
|
|
|
|
-import java.io.FileNotFoundException;
|
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
-import java.io.InputStream;
|
|
|
|
|
-import java.io.PrintStream;
|
|
|
|
|
-import java.util.Properties;
|
|
|
|
|
-import java.util.logging.Logger;
|
|
|
|
|
import org.springframework.boot.SpringApplication;
|
|
import org.springframework.boot.SpringApplication;
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
import org.springframework.boot.context.event.ApplicationPreparedEvent;
|
|
import org.springframework.boot.context.event.ApplicationPreparedEvent;
|
|
@@ -20,6 +12,10 @@ import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Profile;
|
|
import org.springframework.context.annotation.Profile;
|
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
|
|
|
|
|
|
|
|
+import java.io.*;
|
|
|
|
|
+import java.util.Properties;
|
|
|
|
|
+import java.util.logging.Logger;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 应用入口
|
|
* 应用入口
|
|
@@ -33,41 +29,44 @@ public class Application {
|
|
|
|
|
|
|
|
private static final Logger logger = Logger.getLogger(SSOConfigurer.class.getName());
|
|
private static final Logger logger = Logger.getLogger(SSOConfigurer.class.getName());
|
|
|
|
|
|
|
|
|
|
+ public static void main(String[] args) throws FileNotFoundException {
|
|
|
|
|
+ File logFile = new File("logs/log.log");
|
|
|
|
|
+ if (!logFile.getParentFile().exists()) {
|
|
|
|
|
+ logFile.getParentFile().mkdir();
|
|
|
|
|
+ }
|
|
|
|
|
+ System.setErr(new PrintStream(new FileOutputStream(logFile, true)));
|
|
|
|
|
+ SpringApplication application = new SpringApplication(Application.class);
|
|
|
|
|
+ application.addListeners(new ApplicationListener<ApplicationPreparedEvent>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onApplicationEvent(ApplicationPreparedEvent event) {
|
|
|
|
|
+ ContextUtils.setApplicationContext(event.getApplicationContext());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ application.run(args);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Bean(name = "accountConfigurer")
|
|
@Bean(name = "accountConfigurer")
|
|
|
@Profile(value = {"dev"})
|
|
@Profile(value = {"dev"})
|
|
|
public AccountConfigurer devAccountConfigurer(ApplicationContext applicationContext) {
|
|
public AccountConfigurer devAccountConfigurer(ApplicationContext applicationContext) {
|
|
|
-
|
|
|
|
|
- AccountConfigurer configurer = new AccountConfigurer();
|
|
|
|
|
-// configurer.setConfigPath("account-dev.properties");
|
|
|
|
|
-
|
|
|
|
|
- // 解决Spring Boot应用不支持Resource.getFile方式读取配置文件的问题
|
|
|
|
|
- Properties prop = getProperties(applicationContext, "classpath:config/account-dev.properties");
|
|
|
|
|
-
|
|
|
|
|
- if (prop != null) {
|
|
|
|
|
- configurer.initProperties(prop);
|
|
|
|
|
- } else {
|
|
|
|
|
- logger.severe("Initializing is not available AccountConfigLocation on the classpath");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return configurer;
|
|
|
|
|
|
|
+ return accountConfigurer(applicationContext, "classpath:config/account-dev.properties");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "accountConfigurer")
|
|
@Bean(name = "accountConfigurer")
|
|
|
@Profile(value = {"test", "prod"})
|
|
@Profile(value = {"test", "prod"})
|
|
|
public AccountConfigurer prodAccountConfigurer(ApplicationContext applicationContext) {
|
|
public AccountConfigurer prodAccountConfigurer(ApplicationContext applicationContext) {
|
|
|
|
|
+ return accountConfigurer(applicationContext, "classpath:account-prod.properties");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ private AccountConfigurer accountConfigurer(ApplicationContext applicationContext, String location) {
|
|
|
AccountConfigurer configurer = new AccountConfigurer();
|
|
AccountConfigurer configurer = new AccountConfigurer();
|
|
|
-// configurer.setConfigPath("account-dev.properties");
|
|
|
|
|
-
|
|
|
|
|
// 解决Spring Boot应用不支持Resource.getFile方式读取配置文件的问题
|
|
// 解决Spring Boot应用不支持Resource.getFile方式读取配置文件的问题
|
|
|
- Properties prop = getProperties(applicationContext, "classpath:account-prod.properties");
|
|
|
|
|
|
|
+ Properties prop = getProperties(applicationContext, location);
|
|
|
|
|
|
|
|
if (prop != null) {
|
|
if (prop != null) {
|
|
|
configurer.initProperties(prop);
|
|
configurer.initProperties(prop);
|
|
|
} else {
|
|
} else {
|
|
|
logger.severe("Initializing is not available AccountConfigLocation on the classpath");
|
|
logger.severe("Initializing is not available AccountConfigLocation on the classpath");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return configurer;
|
|
return configurer;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -82,20 +81,4 @@ public class Application {
|
|
|
}
|
|
}
|
|
|
return prop;
|
|
return prop;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public static void main(String[] args) throws FileNotFoundException {
|
|
|
|
|
- File logFile = new File("logs/log.log");
|
|
|
|
|
- if (!logFile.getParentFile().exists()) {
|
|
|
|
|
- logFile.getParentFile().mkdir();
|
|
|
|
|
- }
|
|
|
|
|
- System.setErr(new PrintStream(new FileOutputStream(logFile, true)));
|
|
|
|
|
- SpringApplication application = new SpringApplication(Application.class);
|
|
|
|
|
- application.addListeners(new ApplicationListener<ApplicationPreparedEvent>() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onApplicationEvent(ApplicationPreparedEvent event) {
|
|
|
|
|
- ContextUtils.setApplicationContext(event.getApplicationContext());
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- application.run(args);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|