From ea029117bccb6a166a4aced3b26924095dc97392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=E6=BC=8F=E6=B4=9E?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=8C=E6=88=90?= <> Date: Wed, 23 Jul 2025 22:56:42 +0800 Subject: [PATCH] add pg --- admin-client-temperature.iml | 259 ++++++++++++++++++ pom.xml | 10 +- .../AdminClientTemperatureApplication.java | 12 +- .../controller/JdbcDemoController.java | 5 +- src/main/resources/application.yml | 6 +- 5 files changed, 285 insertions(+), 7 deletions(-) create mode 100644 admin-client-temperature.iml diff --git a/admin-client-temperature.iml b/admin-client-temperature.iml new file mode 100644 index 0000000..3119143 --- /dev/null +++ b/admin-client-temperature.iml @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 03a1c97..4a72afe 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.rehome admin-client-temperature 1.0.0 - jar + war admin-client-temperature admin-client-temperature @@ -26,6 +26,12 @@ org.springframework.boot spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + org.mybatis.spring.boot @@ -277,7 +283,7 @@ - ${project.artifactId}-pg + ${project.artifactId}-pg-26-appserver org.springframework.boot diff --git a/src/main/java/com/rehome/mqttclienttemperature/AdminClientTemperatureApplication.java b/src/main/java/com/rehome/mqttclienttemperature/AdminClientTemperatureApplication.java index 74b31b7..60c443f 100644 --- a/src/main/java/com/rehome/mqttclienttemperature/AdminClientTemperatureApplication.java +++ b/src/main/java/com/rehome/mqttclienttemperature/AdminClientTemperatureApplication.java @@ -22,7 +22,7 @@ import java.util.Map; @EnableScheduling @EnableAsync @SpringBootApplication -public class AdminClientTemperatureApplication implements CommandLineRunner, ApplicationContextAware { +public class AdminClientTemperatureApplication extends SpringBootServletInitializer implements CommandLineRunner, ApplicationContextAware { /** * 获取Spring框架的上下文 @@ -69,4 +69,14 @@ public class AdminClientTemperatureApplication implements CommandLineRunner, App public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } + + /** + * @date 2021-05-18 09:20 + * @description: 容器配置,springboot打war包布署必须添加这个配置 为了打包springboot项目 + * @Param: SpringApplicationBuilder + */ + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { + return builder.sources(AdminClientTemperatureApplication.class); + } } \ No newline at end of file diff --git a/src/main/java/com/rehome/mqttclienttemperature/controller/JdbcDemoController.java b/src/main/java/com/rehome/mqttclienttemperature/controller/JdbcDemoController.java index 1cb256e..639865d 100644 --- a/src/main/java/com/rehome/mqttclienttemperature/controller/JdbcDemoController.java +++ b/src/main/java/com/rehome/mqttclienttemperature/controller/JdbcDemoController.java @@ -98,7 +98,7 @@ public class JdbcDemoController { * * @return */ - @RequestMapping("/api/list") + //@RequestMapping("/api/list") public ResponseDto queryList() { // 自定义一个线程池,内部包含8个线程 ExecutorService customPool = Executors.newFixedThreadPool(2); @@ -107,7 +107,7 @@ public class JdbcDemoController { CompletableFuture future = CompletableFuture.supplyAsync(() -> { String sql = "select * from temperature where id = ?"; List jdbcParamValues = new ArrayList<>(); - for (int i = 2371364; i < 2370470; i++) { + for (int i = 0; i < 2390470; i++) { jdbcParamValues.add(i + 1); Gson gson = new Gson(); ResponseDto responseDto = JdbcUtil.executeSql(ds, sql, jdbcParamValues); @@ -120,6 +120,7 @@ public class JdbcDemoController { log.info(gson.toJson(responseTemperatureDto.getData().get(0))); TemperatureDto dto = responseTemperatureDto.getData().get(0); Temperature temperature = new Temperature(); + temperature.setId(dto.getId()); temperature.setCreateDate(dto.getCreateDate()); temperature.setDataDate(dto.getDataDate()); temperature.setDataHour(dto.getDataHour()); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b7da9a6..1b53ba5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,11 +1,13 @@ server: - port: 8874 + port: 8873 shutdown: graceful #开启优雅关闭 # 日志配置 logging: level: root: INFO +# file: +# path: /root/temperature_war spring: datasource: @@ -20,7 +22,7 @@ spring: #url: jdbc:mysql://192.168.3.24:3306/appserver?useUnicode=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true #url: jdbc:mysql://192.168.1.24:3306/appserver?useUnicode=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true #url: jdbc:mysql://47.242.184.139:3306/appserver?useUnicode=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true - url: jdbc:postgresql://192.168.3.24:5432/postgres + url: jdbc:postgresql://192.168.3.26:5432/appserver driverClassName: org.postgresql.Driver #com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver username: postgres password: 452131wW