Filter a certain class or class when maven is packaged

We encountered a problem during development. We wanted to make the springboot project into a jar package to be referenced by other projects. During the operation, we found that when scanning the jar package, the annotations in the startup class of the jar package were repeatedly initialized (because the main project and There is a startup class in the referenced jar. At this time, springboot will start twice, which will trigger the loading of spring.factories in other jar packages (this file can be used to Baidu) twice, causing errors), so there is a demand , Remove the startup class when packaging the jar package, and it didn’t work when ignoring this class when trying various packages. Finally, it was found that it was not removed when packaging, but when compiling. The following is in the pom specific code

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>**/LonchBiPatApplication.java</exclude>
					</excludes>
				</configuration>
			</plugin>
		</plugins>
	</build>

Guess you like

Origin blog.csdn.net/fengbaozonghuiguoqu/article/details/123420905