外部配置读取相对路径

This commit is contained in:
jiangzeyin 2019-03-05 16:07:59 +08:00
parent e67b430e96
commit 4f8b4d795e
5 changed files with 17 additions and 7 deletions

View File

@ -22,7 +22,7 @@
<!--复制外部配置文件-->
<fileSet>
<directory>${basedir}/src/main/resources/bin/</directory>
<outputDirectory>/lib/</outputDirectory>
<outputDirectory>/</outputDirectory>
<includes>
<include>extConfig.yml</include>
</includes>

View File

@ -33,7 +33,7 @@ public class ExtConfigBean {
String path = (home.getSource() == null ? "" : home.getSource().getAbsolutePath());
File file = new File(path);
if (file.isFile()) {
file = file.getParentFile();
file = file.getParentFile().getParentFile();
} else {
file = new File(file, "bin");
}

View File

@ -18,8 +18,11 @@ import java.io.IOException;
*/
public class ExtConfigEnvironmentPostProcessor implements EnvironmentPostProcessor {
private static ConfigurableEnvironment configurableEnvironment;
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
configurableEnvironment = environment;
File directory = ExtConfigBean.getFile();
if (!directory.exists()) {
return;

View File

@ -11,6 +11,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.boot.ApplicationHome;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@ -67,9 +68,15 @@ public class WebAopLog extends PropertyDefinerBase {
public String getPropertyValue() {
String path = JpomApplication.getArgs("jpom.log");
if (StrUtil.isEmpty(path)) {
File directory = new File("");
directory = new File(directory.getAbsolutePath(), "log");
path = directory.getPath();
//
ApplicationHome home = new ApplicationHome(WebAopLog.class);
path = (home.getSource() == null ? "" : home.getSource().getAbsolutePath());
File file = new File(path);
if (file.isFile()) {
file = file.getParentFile().getParentFile();
}
file = new File(file, "log");
path = file.getPath();
}
// 配置默认日志路径
DefaultSystemLog.configPath(path, false);

View File

@ -96,7 +96,7 @@
id: 'table_project',
elem: '#tab_project',
url: '/manage/getProjectInfo',
height: 'full-52',
// height: 'full-52',
even: true,
cols: [[{
field: 'name', title: '项目名称', width: '15%', templet: function (d) {
@ -248,7 +248,7 @@
function reloadTable() {
table.reload('table_project', {
height: 'full-52'
// height: 'full-52'
});
}
</script>