1.網上下載的開源的rocketmq,自己改了下pom檔案,生成zip的壓縮包,打包后運行,
這是zip解壓后的圖片

通過start.sh啟動jar包,在windows下進行的操作
報錯 提示Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication,
這是jar包解壓后的截圖

檔案里面包含了啟動類

2.這是我修改后的pom,主要改的是build標簽下的內容
<build>
<resources>
<!--將resources下的組態檔拷貝到target/config目錄下 -->
<resource>
<directory>src/main/resources</directory>
<targetPath>${project.build.directory}/config</targetPath>
</resource>
<!--編譯的時候,類路徑下也復制一份組態檔(防止開發啟動的時候讀取不到配置的情況) -->
<resource>
<directory>src/main/resources</directory>
<targetPath>${project.build.directory}/classes</targetPath>
</resource>
</resources>
<plugins>
<!-- 將所依賴的第三方jar包打入target下的lib目錄 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- 解決資源檔案的編碼問題 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- 打jar包的main方法配置 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>org.apache.rocketmq.console.App</mainClass>
</manifest>
</archive>
<!--打包的時候忽略classes 路徑下的組態檔 -->
<excludes>
<exclude>*.properties</exclude>
<exclude>*.xml</exclude>
<exclude>*.txt</exclude>
<exclude>static/**</exclude>
<exclude>templates/**</exclude>
</excludes>
</configuration>
</plugin>
<!-- 打zip包 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<compilerVersion>${maven.compiler.source}</compilerVersion>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.2.RELEASE</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
</plugin>
</plugins>
</build>
3.剛下載下來,編譯成jar包沒有任何問題,編譯成zip包就有這個問題,這是我改成zip格式的target的檔案截圖,誰能給點思路,謝謝各位了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/234025.html
標籤:Java SE
上一篇:Java中繼承問題
