Эх сурвалжийг харах

refactor:使用jdk17,加入logo图片,使用jpackage命令打包

yang yi 11 сар өмнө
parent
commit
9cda4e0870

+ 58 - 2
pom.xml

@@ -7,12 +7,23 @@
     <groupId>space.anyi</groupId>
     <groupId>space.anyi</groupId>
     <artifactId>amount-verification</artifactId>
     <artifactId>amount-verification</artifactId>
     <version>0.0.1</version>
     <version>0.0.1</version>
+    <packaging>jar</packaging>
     <dependencies>
     <dependencies>
         <!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel -->
         <!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel -->
         <dependency>
         <dependency>
             <groupId>com.alibaba</groupId>
             <groupId>com.alibaba</groupId>
             <artifactId>easyexcel</artifactId>
             <artifactId>easyexcel</artifactId>
             <version>4.0.3</version>
             <version>4.0.3</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.commons</groupId>
+                    <artifactId>commons-io</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>commons-codec</groupId>
+                    <artifactId>commons-codec</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         </dependency>
         <!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox -->
         <!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox -->
         <dependency>
         <dependency>
@@ -20,11 +31,56 @@
             <artifactId>pdfbox</artifactId>
             <artifactId>pdfbox</artifactId>
             <version>3.0.6</version>
             <version>3.0.6</version>
         </dependency>
         </dependency>
+        <dependency>
+            <groupId>org.openjfx</groupId>
+            <artifactId>javafx-controls</artifactId>
+            <version>21.0.1</version>
+        </dependency>
     </dependencies>
     </dependencies>
 
 
     <properties>
     <properties>
-        <maven.compiler.source>8</maven.compiler.source>
-        <maven.compiler.target>8</maven.compiler.target>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
     </properties>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>1.4</version>
+                <configuration>
+                    <createDependencyReducedPom>true</createDependencyReducedPom>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <transformers>
+                                <transformer
+                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                                    <mainClass>space.anyi.amountVerification.Main</mainClass>
+                                </transformer>
+                            </transformers>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <!--<plugin>-->
+            <!--    <groupId>org.springframework.boot</groupId>-->
+            <!--    <artifactId>spring-boot-maven-plugin</artifactId>-->
+            <!--    <executions>-->
+            <!--        <execution>-->
+            <!--            <goals>-->
+            <!--                <goal>repackage</goal>-->
+            <!--            </goals>-->
+            <!--        </execution>-->
+            <!--    </executions>-->
+            <!--</plugin>-->
+        </plugins>
+    </build>
 
 
 </project>
 </project>

+ 2 - 4
src/main/java/space/anyi/amountVerification/App.java

@@ -10,6 +10,7 @@ import javafx.geometry.Insets;
 import javafx.geometry.Pos;
 import javafx.geometry.Pos;
 import javafx.scene.Scene;
 import javafx.scene.Scene;
 import javafx.scene.control.*;
 import javafx.scene.control.*;
+import javafx.scene.image.Image;
 import javafx.scene.layout.BorderPane;
 import javafx.scene.layout.BorderPane;
 import javafx.scene.layout.GridPane;
 import javafx.scene.layout.GridPane;
 import javafx.scene.layout.VBox;
 import javafx.scene.layout.VBox;
@@ -95,15 +96,12 @@ public class App extends Application {
         this.pattern = Pattern.compile(regex);
         this.pattern = Pattern.compile(regex);
     }
     }
 
 
-    public static void main(String[] args) {
-        Application.launch(App.class, args);
-    }
-
     @Override
     @Override
     public void start(Stage primaryStage) throws Exception {
     public void start(Stage primaryStage) throws Exception {
         this.primaryStage = primaryStage;
         this.primaryStage = primaryStage;
         primaryStage.setTitle("金额验证工具");
         primaryStage.setTitle("金额验证工具");
         primaryStage.setResizable(false);
         primaryStage.setResizable(false);
+        primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/logo.jpg")));
         // 设置窗口关闭事件处理
         // 设置窗口关闭事件处理
         primaryStage.setOnCloseRequest(event -> {
         primaryStage.setOnCloseRequest(event -> {
             event.consume(); // 阻止默认关闭行为
             event.consume(); // 阻止默认关闭行为

+ 16 - 0
src/main/java/space/anyi/amountVerification/Main.java

@@ -0,0 +1,16 @@
+package space.anyi.amountVerification;
+
+import javafx.application.Application;
+
+/**
+ * @ProjectName: amount-verification
+ * @FileName: Main
+ * @Author: 杨逸
+ * @Data:2025/11/27 22:12
+ * @Description:
+ */
+public class Main {
+    public static void main(String[] args) {
+        Application.launch(App.class, args);
+    }
+}

BIN
src/main/resources/logo.jpg


+ 1 - 0
src/main/resources/package

@@ -0,0 +1 @@
+jpackage --type app-image --name amountVerify --input target --main-jar amount-verification-0.0.1.jar  --dest dist