4 Commits

Author SHA1 Message Date
1231fe3132 保存进度! 2022-05-10 16:03:40 +08:00
fbe9f8e532 完成打包! 2022-05-10 14:24:07 +08:00
53849e4f74 保存进度! 2022-05-09 17:03:26 +08:00
d1bcb3b956 保存进度! 2022-05-06 17:33:56 +08:00
7 changed files with 87 additions and 23 deletions

View File

@@ -133,4 +133,7 @@ $RECYCLE.BIN/
# Windows shortcuts # Windows shortcuts
*.lnk *.lnk
target/* target/*
logs/*
logs

View File

@@ -0,0 +1,10 @@
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
.level = INFO
java.util.logging.FileHandler.pattern = ./logs/log_%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.append = true;

View File

@@ -23,7 +23,7 @@
<version>4.13.2</version> <version>4.13.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <!-- <dependency>
<groupId>commons-beanutils</groupId> <groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId> <artifactId>commons-beanutils</artifactId>
<version>1.9.4</version> <version>1.9.4</version>
@@ -53,7 +53,7 @@
<artifactId>json-lib</artifactId> <artifactId>json-lib</artifactId>
<version>2.4</version> <version>2.4</version>
<classifier>jdk15</classifier> <classifier>jdk15</classifier>
</dependency> </dependency> -->
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
@@ -79,10 +79,39 @@
</properties> </properties>
<build> <build>
<defaultGoal>compile</defaultGoal> <defaultGoal>compile</defaultGoal>
<plugins> <plugins>
<!-- <plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M6</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
</plugin> --> <configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>AppMain</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assmenbly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles> <profiles>

View File

@@ -2,7 +2,7 @@
* @Author: Kane * @Author: Kane
* @Date: 2022-04-22 10:53:49 * @Date: 2022-04-22 10:53:49
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2022-05-06 11:08:07 * @LastEditTime: 2022-05-10 16:01:13
* @FilePath: \DisasterWarning\src\main\java\AppMain.java * @FilePath: \DisasterWarning\src\main\java\AppMain.java
* @Description: 和风天气预警推送厦门太保公众号主程序! * @Description: 和风天气预警推送厦门太保公众号主程序!
* *
@@ -13,7 +13,7 @@ import com.cpic.xim.notify.disaster.QWeatherDisasterWarning;
import com.cpic.xim.notify.disaster.WeatherDisasterWarningGrabber; import com.cpic.xim.notify.disaster.WeatherDisasterWarningGrabber;
import com.cpic.xim.wechat.officalAccount.sendMessage; import com.cpic.xim.wechat.officalAccount.sendMessage;
import com.cpic.xim.config.WeatherDisasterNotifyConfig; import com.cpic.xim.config.WeatherDisasterNotifyConfig;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Vector; import java.util.Vector;
@@ -22,7 +22,7 @@ import java.util.logging.*;
public class AppMain public class AppMain
{ {
private final static String LOG_FILE_PATH = "./app.log"; // private final static String LOG_FILE_PATH = "./logs/app%u.log";
public static void main( String[] args ) public static void main( String[] args )
{ {
@@ -45,7 +45,6 @@ public class AppMain
return; return;
} }
// 读取配置 // 读取配置
try try
{ {
@@ -80,6 +79,8 @@ public class AppMain
// 判断是否有警报 // 判断是否有警报
if ( warning.getWarning().isEmpty() == true) if ( warning.getWarning().isEmpty() == true)
{ {
logger.log( Level.INFO, "查询{0}天气预警,无警报!。", new Object[]
{ city.getCityName()} );
continue; continue;
} }
@@ -126,17 +127,29 @@ public class AppMain
*/ */
private static void setRootLogger() throws IOException private static void setRootLogger() throws IOException
{ {
// Logger rootLogger = Logger.getLogger( "com.cpicxim" );
// ConsoleHandler consoleHandler = new ConsoleHandler();
// FileHandler fileHandler = new FileHandler( LOG_FILE_PATH );
// SimpleFormatter formatter = new SimpleFormatter();
// consoleHandler.setFormatter( formatter );
// fileHandler.setFormatter( formatter );
// rootLogger.addHandler( consoleHandler );
// rootLogger.addHandler( fileHandler );
// rootLogger.setUseParentHandlers( false );
// rootLogger.setLevel( Level.ALL );
LogManager logManager = LogManager.getLogManager();
// 使用外部的配置文件。
FileInputStream configFile = new FileInputStream( "./logging.properties" );
// 使用jar中的配置文件。
// InputStream configFile =
// AppMain.class.getClassLoader().getResourceAsStream( "logging.properties" );
logManager.readConfiguration( configFile );
Logger rootLogger = Logger.getLogger( "com.cpicxim" ); Logger rootLogger = Logger.getLogger( "com.cpicxim" );
ConsoleHandler consoleHandler = new ConsoleHandler();
FileHandler fileHandler = new FileHandler( LOG_FILE_PATH );
SimpleFormatter formatter = new SimpleFormatter();
consoleHandler.setFormatter( formatter );
fileHandler.setFormatter( formatter );
rootLogger.addHandler( consoleHandler );
rootLogger.addHandler( fileHandler );
rootLogger.setUseParentHandlers( false );
rootLogger.setLevel( Level.ALL );
} }
} }

View File

@@ -0,0 +1,10 @@
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
.level = INFO
java.util.logging.FileHandler.pattern = ./logs/log_%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 10
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.append = true;

View File

@@ -2,7 +2,7 @@
* @Author: Kane * @Author: Kane
* @Date: 2022-04-22 10:53:49 * @Date: 2022-04-22 10:53:49
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2022-05-06 11:14:35 * @LastEditTime: 2022-05-10 11:33:41
* @FilePath: \DisasterWarning\src\test\java\com\cpic\xim\wechat\officalAccount\sendMessageTest.java * @FilePath: \DisasterWarning\src\test\java\com\cpic\xim\wechat\officalAccount\sendMessageTest.java
* @Description: * @Description:
* *
@@ -12,7 +12,6 @@ package com.cpic.xim.wechat.officalAccount;
import com.cpic.xim.notify.disaster.QWeatherDisasterWarning; import com.cpic.xim.notify.disaster.QWeatherDisasterWarning;
import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import com.cpic.xim.httpUtil.*; import com.cpic.xim.httpUtil.*;
import java.io.IOException; import java.io.IOException;
@@ -61,7 +60,7 @@ public class sendMessageTest
} }
@Test // @Test
public void testSendWeatherDisasterWarning() throws IOException public void testSendWeatherDisasterWarning() throws IOException
{ {
String warningJSON = String warningJSON =