This problem is that when spring is used, the local IDE runs normally, but an error is reported when running on the cluster after packaging.
After searching for information, the source of the problem was determined. Since many spring packages were called in the dependencies, there would be file coverage.
specifically is
These three files. After checking, only the configuration of tx is left.
Solution
The first method is to use maven’s packaging plug-in, which retains the configuration information of each spring package:
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version> 1.7.1</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <transformers>
- <transformer
- implementation=“org.apache.maven.plugins.shade.resource.AppendingTransformer”>
- <resource>META-INF/spring.handlers</resource>
- </transformer>
- <transformer
- implementation=“org.apache.maven.plugins.shade.resource.AppendingTransformer”>
- <resource>META-INF/spring.schemas</resource>
- </transformer>
- <transformer
- implementation=“org.apache.maven.plugins.shade.resource.ManifestResourceTransformer”>
- <mainClass>com.chenzhou.test.Main</mainClass>
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
But this method is limited to packaging with this maven plugin. In fact, as long as these three files can contain complete configuration information, it’s fine.
The second method is actually very simple. Find these three files and overwrite them with the three complete files I provided.
Usually, these three files are in the META-INF path under the jar package
Similar Posts:
- Remove dependency-reduced-pom.xml file when packaging Maven project
- Intellij Pack the jar file error: “java.lang.SecurityException: Invalid signature file digest for Manifest main attrib
- Maven no main manifest attribute when generate jar for project
- [Solved] Unable to import Maven project: see logs for details when importing Maven dependent package of Spark Program
- Run jar file under Linux system, prompt: no main manifest attribute, in xxx.jar [How to Solve]
- [Solved] SpringBoot Package Error: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-res
- [Solved] Spring Start Error: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project gulimall-coupon: There are test failures. Please refer to D:\m1\0613\mall-coup
- [Solved] Spring Boot Package Error: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0
- Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.5. RELEASE:repackage (repackage) on project tristone-boot-module-system: zip file is empty
- [Solved] SpringBoot Project Package to jar Error: ClassNotFound…