Commit fdd2acfc by zt

修改-linux服务器上不设置配置文件就加载默认的, 已解决

parent f1b64f3d
......@@ -15,6 +15,7 @@
</properties>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
......@@ -68,7 +69,6 @@
<version>5.1.4.RELEASE</version>
</dependency>
<!-- 封装实体依赖 -->
<dependency>
<groupId>org.projectlombok</groupId>
......
......@@ -5,11 +5,8 @@ import com.foc.entity.AccessInfo;
import com.foc.entity.SmsResult;
import com.foc.service.Sms;
import com.foc.service.SoundMonitorService;
import com.foc.util.PropertiesUtils;
import lombok.extern.log4j.Log4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.Properties;
......@@ -29,7 +26,10 @@ public class DbSoundsMonitorTask {
public static void main(String[] args) throws Exception {
if (args == null || args.length == 0){
loadConf(Thread.currentThread().getContextClassLoader().getResource("global.properties").getPath());
//本地启动是可以。到了服务器变成了java.io.FileNotFoundException: file:/data/smsAndEmailTest/task-3.0-SNAPSHOT.jar!/global.properties (No such file or directory)
//loadConf(Thread.currentThread().getContextClassLoader().getResource("global.properties").getPath());
Properties properties = PropertiesUtils.getProperties();
load(properties);
}else {
loadConf(args[0]);
}
......@@ -37,6 +37,10 @@ public class DbSoundsMonitorTask {
public static void loadConf(String path) throws Exception {
Properties properties = PropertiesUtils.getProperties(path);
load(properties);
}
public static void load(Properties properties){
String aicc = properties.getProperty("aicc");
String aicp = properties.getProperty("aicp");
String resultCode = properties.getProperty("resultCode");
......@@ -59,4 +63,5 @@ public class DbSoundsMonitorTask {
log.info("没有异常!" );
}
}
}
......@@ -34,7 +34,7 @@ public class PropertiesUtils {
if (properties == null){
properties = new Properties();
try {
properties.load(new InputStreamReader(PropertiesUtils.class.getClassLoader().getResourceAsStream("server.properties"),"UTF-8"));
properties.load(new InputStreamReader(PropertiesUtils.class.getClassLoader().getResourceAsStream("global.properties"),"UTF-8"));
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -47,7 +47,7 @@
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<!--<property name="url" value="jdbc:mysql://106.75.97.50:3306/jd_foc"/>-->
<property name="url" value=" jdbc:mysql://mysql_server:3306/foc?useUnicode=true&characterEncoding=utf-8"/>
<property name="url" value="jdbc:mysql://mysql_server:3306/foc?useUnicode=true&amp;characterEncoding=utf-8"/>
<property name="username" value="focuser"/>
<property name="password" value="FOC@2016"/>
</dataSource>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment