1.需要在pom.xml中指定主类

<build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <!-- 工程主入口-->
          <mainClass>org.example.App</mainClass>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

然后使用maven package打包
在这里插入图片描述

2.运行时指令需要使用java -jar

java -jar xxx.jar

3.如果Idea编译客户端能正常解析,但是maven打包后客户端接收中文乱码,可以在运行jar时指定编码

 java -jar  -Dfile.encoding=utf-8 xxx.jar
Logo

一站式 AI 云服务平台

更多推荐