Commit fdd2acfc by zt

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

parent f1b64f3d
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
...@@ -68,7 +69,6 @@ ...@@ -68,7 +69,6 @@
<version>5.1.4.RELEASE</version> <version>5.1.4.RELEASE</version>
</dependency> </dependency>
<!-- 封装实体依赖 --> <!-- 封装实体依赖 -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
......
...@@ -5,11 +5,8 @@ import com.foc.entity.AccessInfo; ...@@ -5,11 +5,8 @@ import com.foc.entity.AccessInfo;
import com.foc.entity.SmsResult; import com.foc.entity.SmsResult;
import com.foc.service.Sms; import com.foc.service.Sms;
import com.foc.service.SoundMonitorService; import com.foc.service.SoundMonitorService;
import com.foc.util.PropertiesUtils; import com.foc.util.PropertiesUtils;
import lombok.extern.log4j.Log4j; import lombok.extern.log4j.Log4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import java.util.Properties; import java.util.Properties;
...@@ -29,7 +26,10 @@ public class DbSoundsMonitorTask { ...@@ -29,7 +26,10 @@ public class DbSoundsMonitorTask {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
if (args == null || args.length == 0){ 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 { }else {
loadConf(args[0]); loadConf(args[0]);
} }
...@@ -37,6 +37,10 @@ public class DbSoundsMonitorTask { ...@@ -37,6 +37,10 @@ public class DbSoundsMonitorTask {
public static void loadConf(String path) throws Exception { public static void loadConf(String path) throws Exception {
Properties properties = PropertiesUtils.getProperties(path); Properties properties = PropertiesUtils.getProperties(path);
load(properties);
}
public static void load(Properties properties){
String aicc = properties.getProperty("aicc"); String aicc = properties.getProperty("aicc");
String aicp = properties.getProperty("aicp"); String aicp = properties.getProperty("aicp");
String resultCode = properties.getProperty("resultCode"); String resultCode = properties.getProperty("resultCode");
...@@ -59,4 +63,5 @@ public class DbSoundsMonitorTask { ...@@ -59,4 +63,5 @@ public class DbSoundsMonitorTask {
log.info("没有异常!" ); log.info("没有异常!" );
} }
} }
} }
...@@ -34,7 +34,7 @@ public class PropertiesUtils { ...@@ -34,7 +34,7 @@ public class PropertiesUtils {
if (properties == null){ if (properties == null){
properties = new Properties(); properties = new Properties();
try { 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) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<dataSource type="POOLED"> <dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/> <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://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="username" value="focuser"/>
<property name="password" value="FOC@2016"/> <property name="password" value="FOC@2016"/>
</dataSource> </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