1. <build>
    2. <plugins>
    3. <plugin>
    4. <groupId>org.apache.maven.plugins</groupId>
    5. <artifactId>maven-jar-plugin</artifactId>
    6. <configuration>
    7. <archive>
    8. <manifest>
    9. <mainClass>com.example.demo.TestKey</mainClass>
    10. <addClasspath>true</addClasspath>
    11. </manifest>
    12. </archive>
    13. </configuration>
    14. </plugin>
    15. </plugins>
    16. </build>

    image.png

    定义一个 java 启动类

    1. package com.example.demo;
    2. public class TestKey {
    3. public static void main(String[] args) {
    4. System.out.println("启动了.............");
    5. }
    6. }
    1. <build>
    2. <finalName>${project.artifactId}</finalName>
    3. <plugins>
    4. <plugin>
    5. <artifactId>maven-assembly-plugin</artifactId>
    6. <configuration>
    7. <!--这部分可有可无,加上的话则直接生成可运行jar包-->
    8. <archive>
    9. <manifest>
    10. <mainClass>com.slf.oled.Demo</mainClass>
    11. </manifest>
    12. </archive>
    13. <descriptorRefs>
    14. <descriptorRef>jar-with-dependencies</descriptorRef>
    15. </descriptorRefs>
    16. </configuration>
    17. </plugin>
    18. </plugins>
    19. </build>

    image.png
    image.png