多Jar包部署问题

287 阅读1分钟

在多启动类多jar的项目中,打包时:在根pom进行package即可打包完成。

image.png

打包后进行部署有启动类的jar包时,报错 xxx.jar中没有主清单属性,由于springboot的打包要求,咱需要在有启动类的项目中需要加入pom.xml需要加入build

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

这样再重新打包即可。

再启动过程中,发现了另外一个问题, jar启动报错:org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputExcept:Input lengt..

这是由于咱使用了nacos作为配置中心,在其配置文件中有中文字符,所以会有问题(注释不起作用)。 有两种解决方案

  • 删除中文字符
  • 配置启动参数 -Dfile.encoding=utf-8

这边咱使用java -Dfile.encoding=utf-8 -jar xxx.jar ,来运行项目

image.png