Pārlūkot izejas kodu

refactor: 优化配置

fanyanpeng 1 gadu atpakaļ
vecāks
revīzija
e40d20f606
4 mainītis faili ar 144 papildinājumiem un 13 dzēšanām
  1. 18 12
      Dockerfile
  2. 66 0
      application.yaml
  3. 59 0
      settings.xml
  4. 1 1
      src/main/java/com/njuzr/eaibackend/config/WebConfig.java

+ 18 - 12
Dockerfile

@@ -1,15 +1,21 @@
-#FROM openjdk:17-slim
-#COPY target/*.jar /app/app.jar
-#COPY src/main/resources/application-prod.yaml /app/application.yaml
-#WORKDIR /app
-#CMD ["java", "-jar", "/app/app.jar", "-Duser.timezone=Asia/Shanghai", "--spring.config.location=/app/application.yaml"]
-#EXPOSE 8080
 
+
+# Use an official Maven image as the base image
+FROM maven:3.8.5-openjdk-17-slim AS build
+# Set the working directory in the container
+WORKDIR /app
+# Copy the pom.xml and the project files to the container
+COPY pom.xml .
+COPY src ./src
+# Build the application using Maven
+RUN mvn clean package -DskipTests
+
+# Use an official OpenJDK image as the base image
 FROM openjdk:17-jdk-slim
-# 定义构建时传递的JAR文件名参数
-ARG JAR_FILE
-COPY ${JAR_FILE} /app/app.jar
-COPY application-prod.yaml /app/application.yaml
+# Set the working directory in the container
 WORKDIR /app
-CMD ["java", "-jar", "/app/app.jar", "--spring.config.location=file:/app/application.yaml"]
-EXPOSE 8080
+# Copy the built JAR file from the previous stage to the container
+COPY --from=build /app/target/*.jar ./app.jar
+# Set the command to run the application
+CMD ["java", "-jar", "/app/app.jar","--spring.config.location=file:/app/application.yaml"]
+EXPOSE 8080

+ 66 - 0
application.yaml

@@ -0,0 +1,66 @@
+spring:
+  jackson:
+    deserialization:
+      fail-on-unknown-properties: true
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    username: root
+    password: eai123456
+    url: jdbc:mysql://192.168.80.1:3309/eai?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true
+  data:
+    mongodb:
+      uri: mongodb://admin:eai123456@139.196.252.184:27017/eai?authSource=admin
+      authentication-database: admin
+  mail:
+    host: smtp.163.com
+    port: 25
+    username: seecoder2022@163.com # Seecoder的公共邮箱
+    password: WEIHUIOOJYUFMZGV # 邮箱开启stmp的秘钥
+    default-encoding: UTF-8
+
+
+# MyBatis配置
+mybatis-plus:
+  mapper-locations: classpath:mapper/*.xml
+  type-aliases-package: com/njuzr/eaibackend/po
+
+
+jwt:
+  # jjwt密钥算法HS256,要求secret长度至少是256位
+  secret: xTv@UA7e2q$*n&92AHo5Wj$@KAnguhxTv@UA7e2q$*n&92AHo5Wj$@KAnguhxTv@UA7e2q$*n&92AHo5Wj$@KAnguhxTv@UA7e2q$*n&92AHo5Wj$@KAnguhxTv@UA7e2q$*n&92AHo5Wj$@KAnguhxTv@UA7e2q$*n&92AHo5Wj$@KAnguhxTv@UA7e2q$*n&92AHo5Wj$@KAnguhxTv@UA7e2q$*n&92AHo5Wj$@KAnguh92AHo5Wj$@KAnguh92AHo5Wj$@KAnguh92AHo5Wj$@KAnguh
+  issuer: eai
+  expiration: 86400
+
+
+aliyun:
+  oss:
+    endpoint: oss-cn-shanghai.aliyuncs.com
+    accessKeyId: LTAI5tAbkw8rkreiJbfcY1jZ
+    accessKeySecret: 2yvtVYE1qAZEgm0ChvdMqhp0LhB5Lj
+    bucketName: eai-files
+
+
+logging:
+  config: classpath:log4j2-prod.xml
+
+openai:
+  chatgpt:
+    model: gpt-3.5-turbo
+    api:
+      key: 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
+
+
+config:
+  llm:
+    ChatGLM3: http://10.58.0.2:6678
+    Qwen2-7B: http://10.58.0.2:8000
+    QWen14B: http://10.58.0.2:6679
+
+
+
+proxy:
+  enabled: false
+  host: 20.111.54.16
+  port: 8123
+
+

+ 59 - 0
settings.xml

@@ -0,0 +1,59 @@
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
+                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
+    <localRepository/>
+    <interactiveMode/>
+    <usePluginRegistry/>
+    <offline/>
+    <pluginGroups/>
+    <servers/>
+    <mirrors>
+        <mirror>
+            <id>aliyunmaven</id>
+            <mirrorOf>central</mirrorOf>
+            <name>阿里云公共仓库</name>
+            <url>https://maven.aliyun.com/repository/central</url>
+        </mirror>
+        <mirror>
+            <id>repo1</id>
+            <mirrorOf>central</mirrorOf>
+            <name>central repo</name>
+            <url>http://repo1.maven.org/maven2/</url>
+        </mirror>
+        <mirror>
+            <id>aliyunmaven</id>
+            <mirrorOf>apache snapshots</mirrorOf>
+            <name>阿里云阿帕奇仓库</name>
+            <url>https://maven.aliyun.com/repository/apache-snapshots</url>
+        </mirror>
+    </mirrors>
+    <proxies/>
+    <activeProfiles/>
+    <profiles>
+        <profile>
+            <repositories>
+                <repository>
+                    <id>aliyunmaven</id>
+                    <name>aliyunmaven</name>
+                    <url>https://maven.aliyun.com/repository/public</url>
+                    <layout>default</layout>
+                    <releases>
+                        <enabled>true</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>true</enabled>
+                    </snapshots>
+                </repository>
+                <repository>
+                    <id>MavenCentral</id>
+                    <url>http://repo1.maven.org/maven2/</url>
+                </repository>
+                <repository>
+                    <id>aliyunmavenApache</id>
+                    <url>https://maven.aliyun.com/repository/apache-snapshots</url>
+                </repository>
+            </repositories>
+        </profile>
+    </profiles>
+</settings>

+ 1 - 1
src/main/java/com/njuzr/eaibackend/config/WebConfig.java

@@ -26,7 +26,7 @@ public class WebConfig implements WebMvcConfigurer {
     @Override
     public void addCorsMappings(CorsRegistry registry) {
         registry.addMapping("/**") // 对所有路径应用规则
-                .allowedOrigins(origins)
+                .allowedOriginPatterns("*")
                 .allowedMethods("GET", "POST", "PUT", "DELETE") // 允许的请求方法
                 .allowedHeaders("*") // 允许的请求头
                 .allowCredentials(true) // 允许发送Cookies