From 8aea3ecc955f5c55024686375bc6b2fc3a989a35 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期三, 03 七月 2024 15:44:32 +0800
Subject: [PATCH] zjh 2024/07/3-1

---
 ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java b/ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java
index dbad06b..fa0c84b 100644
--- a/ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java
+++ b/ltkj-framework/src/main/java/com/ltkj/framework/config/DruidConfig.java
@@ -17,6 +17,7 @@
 import com.ltkj.system.service.ISysConfigService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.boot.web.servlet.FilterRegistrationBean;
@@ -39,6 +40,13 @@
 @Slf4j
 public class DruidConfig {
 
+    @Value ("${config.properties}")
+    private  String url;
+
+    @Value ("${config.path}")
+    private  String path;
+
+
     @Bean
 //    @ConfigurationProperties("spring.datasource.druid.master")
     public DataSource masterDataSource(DruidProperties druidProperties) {
@@ -48,15 +56,15 @@
             // 浠庢枃浠朵腑璇诲彇閰嶇疆淇℃伅
             FileInputStream fis = null;
             try {
-                fis = new FileInputStream("D:\\ltkjprojectconf\\config.properties");
+                fis = new FileInputStream(url);
             } catch (FileNotFoundException e) {
                 log.info("鏁版嵁搴撹繛鎺ユ枃浠舵壘涓嶅埌 绯荤粺姝e湪鍒涘缓锛�");
 
-                File f = new File("D:\\ltkjprojectconf");
+                File f = new File(path);
                 if(!f.exists()){
                     f.mkdirs();
                 }
-                File file = new File("D:\\ltkjprojectconf\\config.properties");
+                File file = new File(url);
                 try {
                     FileWriter fileWriter = new FileWriter(file);
                     fileWriter.write("ip = 浣犵殑涓绘暟鎹簱杩炴帴ip鍦板潃\n");
@@ -130,7 +138,7 @@
             // 浠庢枃浠朵腑璇诲彇閰嶇疆淇℃伅
             FileInputStream fis = null;
             try {
-                fis = new FileInputStream("D:\\ltkjprojectconf\\config.properties");
+                fis = new FileInputStream(url);
             } catch (FileNotFoundException e) {
                 log.info("鏁版嵁搴撹繛鎺ユ枃浠舵壘涓嶅埌锛�");
             }
@@ -164,7 +172,7 @@
             // 浠庢枃浠朵腑璇诲彇閰嶇疆淇℃伅
             FileInputStream fis = null;
             try {
-                fis = new FileInputStream("D:\\ltkjprojectconf\\config.properties");
+                fis = new FileInputStream(url);
             } catch (FileNotFoundException e) {
                 log.info("鏁版嵁搴撹繛鎺ユ枃浠舵壘涓嶅埌锛�");
             }
@@ -198,7 +206,7 @@
             // 浠庢枃浠朵腑璇诲彇閰嶇疆淇℃伅
             FileInputStream fis = null;
             try {
-                fis = new FileInputStream("D:\\ltkjprojectconf\\config.properties");
+                fis = new FileInputStream(url);
             } catch (FileNotFoundException e) {
                 log.info("鏁版嵁搴撹繛鎺ユ枃浠舵壘涓嶅埌");
             }

--
Gitblit v1.8.0