Parcourir la source

feat:修改打包方式,增加日志输出

wuzilong il y a 7 mois
Parent
commit
dfd526ba37
2 fichiers modifiés avec 24 ajouts et 52 suppressions
  1. 8 50
      pom.xml
  2. 16 2
      src/main/java/com/njuzr/eaibackend/EaiBackendApplication.java

+ 8 - 50
pom.xml

@@ -107,7 +107,13 @@
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-ooxml</artifactId>
-            <version>5.2.5</version>
+            <version>5.3.0</version>
+        </dependency>
+        <!-- 添加 POI 核心依赖,解决 AWT 问题 -->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>5.3.0</version>
         </dependency>
 
         <!--csv依赖-->
@@ -165,7 +171,7 @@
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-ooxml</artifactId>
-            <version>5.2.5</version>
+            <version>5.3.0</version>
         </dependency>
 
         <!-- 豆包大语言模型依赖       -->
@@ -222,52 +228,6 @@
 
     <build>
         <plugins>
-            <!-- 使用 maven-shade-plugin 打包所有依赖 -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-shade-plugin</artifactId>
-                <version>3.5.1</version>
-                <executions>
-                    <execution>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>shade</goal>
-                        </goals>
-                        <configuration>
-                            <!-- 创建可执行的 JAR -->
-                            <transformers>
-                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-                                    <mainClass>com.njuzr.eaibackend.EaiBackendApplication</mainClass>
-                                </transformer>
-                                <!-- 合并 META-INF/spring.factories 文件 -->
-                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
-                                    <resource>META-INF/spring.factories</resource>
-                                </transformer>
-                                <!-- 合并 META-INF/spring.components 文件 -->
-                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
-                                    <resource>META-INF/spring.components</resource>
-                                </transformer>
-                            </transformers>
-                            <!-- 排除签名文件,避免冲突 -->
-                            <filters>
-                                <filter>
-                                    <artifact>*:*</artifact>
-                                    <excludes>
-                                        <exclude>META-INF/*.SF</exclude>
-                                        <exclude>META-INF/*.DSA</exclude>
-                                        <exclude>META-INF/*.RSA</exclude>
-                                    </excludes>
-                                </filter>
-                            </filters>
-                            <!-- 生成依赖简化后的文件 -->
-                            <createDependencyReducedPom>false</createDependencyReducedPom>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-
-            <!-- 跳过 spring-boot-maven-plugin,避免冲突 -->
-            <!--
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
@@ -280,8 +240,6 @@
                     </excludes>
                 </configuration>
             </plugin>
-            -->
-
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>

+ 16 - 2
src/main/java/com/njuzr/eaibackend/EaiBackendApplication.java

@@ -4,13 +4,27 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cache.annotation.EnableCaching;
 
+import java.awt.GraphicsEnvironment;
+
 @SpringBootApplication
 @EnableCaching
 public class EaiBackendApplication {
 
-    public static void main(String[] args) {
-        // 设置 headless 模式,解决 Linux 服务器下 AWT 相关问题
+    // 静态初始化块,确保在任何类加载之前设置 headless 模式
+    static {
         System.setProperty("java.awt.headless", "true");
+    }
+
+    public static void main(String[] args) {
+        // 输出调试信息
+        System.out.println("=== AWT Headless Mode Debug Info ===");
+        System.out.println("java.awt.headless property: " + System.getProperty("java.awt.headless"));
+        System.out.println("Is headless: " + GraphicsEnvironment.isHeadless());
+        System.out.println("GraphicsEnvironment class: " + GraphicsEnvironment.class.getName());
+        System.out.println("OS Name: " + System.getProperty("os.name"));
+        System.out.println("OS Version: " + System.getProperty("os.version"));
+        System.out.println("====================================");
+
         SpringApplication.run(EaiBackendApplication.class, args);
     }