解决springboot maven多模块项目打包的时候某个被依赖的模块报错找不到main class

springboot maven 多模块项目打包的时候某个被依赖的模块报错

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.3.RELEASE:
repackage (repackage) on project **-client: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.3.RELEASE:repackage failed:
Unable to find main class -> [Help 1]

这个被依赖的**-client模块并不需要有main类,解决方法是修改父pom.xml

原来的父pom.xml中的标签内容为

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

将父pom.xml中的标签内容改为

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>3.3version>
                <configuration>
                    <source>1.8source>
                    <target>1.8target>
                    <fork>truefork>
                    <verbose>trueverbose>
                    <encoding>UTF-8encoding>
                    <meminitial>256mmeminitial>
                    <maxmem>1024mmaxmem>
                configuration>
            plugin>
        plugins>
    build>

原因可以参考springboot官网
https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html#build-tool-plugins-maven-packaging

Once spring-boot-maven-plugin has been included in your pom.xml,
it automatically tries to rewrite archives to make them executable by using the spring-boot:repackage goal.

你可能感兴趣的:(java,maven,spring,springboot)