Jar不是为春季启动创建的

时间:2018-10-22 13:24:02

标签: java spring maven spring-boot

我正在添加pluginManagement以避免 无法在目标org.apache.openjpa:openjpa-maven-plugin:3.0.0:enhance的项目执行增强器上执行目标org.apache.openjpa:openjpa-maven-plugin:3.0.0:enhance(enhancer) / p>

错误。但是当我添加pluginManagement时,它将停止为我的项目创建jar。

    <build>
         <pluginManagement>
              <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>com.test.testApplication</mainClass>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.6.201602180812</version>
            <configuration>
                <destFile>${sonar.jacoco.reportPath}</destFile>
                <append>true</append>
            </configuration>
            <executions>
                <execution>
                    <id>agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-maven-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <includes>**/tablemodels/*.class</includes>
                <addDefaultConstructor>true</addDefaultConstructor>
                <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
                <persistenceXmlFile>src/main/resources/META-INF/persistence.xml</persistenceXmlFile>
            </configuration>
             <executions>
                <execution>
                    <id>enhancer</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>enhance</goal>
                    </goals>
                </execution>
            </executions> 
        </plugin>
    </plugins>
     </pluginManagement>
</build>

如果我从pom中删除pluginManagement,那么将创建Jar。

1 个答案:

答案 0 :(得分:1)

我的猜测是,您只是将<plugins>标记包装在<pluginManagement>标记中,这并没有完成您想要的操作。建议您阅读the documentation来了解pluginpluginManagement之间的关系。另请参见another post on StackOverflow

关于您的基本问题:我猜您提到的错误是Eclipse错误。它是由m2e插件发出的,该插件需要为pom中的每个maven插件都需要一个连接器。

通常可以通过在您喜欢的搜索引擎中键入“ m2e connector”来提供连接器(如果在Eclipse Marketplace上找不到)。

在这种情况下,您可能需要安装此软件:https://github.com/beskow/openjpa-maven-connector