chore: 加入nacos适配调整

This commit is contained in:
vastlan committed 2024-08-13 17:20:04 +08:00
1 parent ae077a121b
commit 1c274b93c3
9 files changed
+103 -26

No files matched your search

+82 -6
View File
@@ -2,21 +2,74 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- <parent>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-parent</artifactId>-->
<!-- <version>3.2.3</version>-->
<!-- <relativePath/> &lt;!&ndash; lookup parent from repository &ndash;&gt;-->
<!-- </parent>-->
<groupId>com.binary</groupId>
<artifactId>weight</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>weight</name>
<description>Weight project for Spring Boot</description>
<properties>
<java.version>17</java.version>
<spring-boot.version>2.7.15</spring-boot.version>
<spring-cloud.version>2021.0.8</spring-cloud.version>
<maven.compile.source>17</maven.compile.source>
<maven.compile.target>17</maven.compile.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2021.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
@@ -51,10 +104,33 @@
</dependencies>
<build>
<finalName>${project.name}-server</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>${maven.compile.source}</source>
<target>${maven.compile.target}</target>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
@@ -4,7 +4,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
//@EnableScheduling
@EnableScheduling
@SpringBootApplication
public class WeightApplication {
@@ -1,13 +1,14 @@
package com.binary.weight.controller;
import com.binary.weight.service.SSEService;
import jakarta.annotation.Resource;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import javax.annotation.Resource;
@RestController
@CrossOrigin
public class SSEController {
@@ -1,12 +1,12 @@
package com.binary.weight.controller;
import com.binary.weight.service.WeightService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -1,12 +1,12 @@
package com.binary.weight.service;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.util.List;
import java.util.Map;
@@ -1,10 +1,10 @@
package com.binary.weight.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.annotation.Resource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -1,10 +1,10 @@
package com.binary.weight.timer;
import com.binary.weight.service.SyncService;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
@Component
+11 -11
View File
@@ -1,15 +1,15 @@
spring:
datasource:
mysql:
jdbc-url: jdbc:mysql://192.168.1.152:3307/eagle-cloud-plus?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8
username: root
password: Cnqisoft@2020
driver-class-name: com.mysql.cj.jdbc.Driver
sqlserver:
jdbc-url: jdbc:sqlserver://221.179.56.134:51433;DatabaseName=WEIGHT55;encrypt=false;trustServerCertificate=true;
username: sa
password: ABCabc12345
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# datasource:
# mysql:
# jdbc-url: jdbc:mysql://192.168.1.152:3307/eagle-cloud-plus?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8
# username: root
# password: Cnqisoft@2020
# driver-class-name: com.mysql.cj.jdbc.Driver
# sqlserver:
# jdbc-url: jdbc:sqlserver://221.179.56.134:51433;DatabaseName=WEIGHT55;encrypt=false;trustServerCertificate=true;
# username: sa
# password: ABCabc12345
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
profiles:
active: prod
+2 -2
View File
@@ -1,6 +1,6 @@
spring:
application:
name: dispatch-server
name: weighbridge-server
cloud:
nacos:
@@ -9,4 +9,4 @@ spring:
file-extension: yaml
discovery:
ip: 192.168.1.152
port: 8006
port: 8005