【问题标题】:Jar is not creating for spring bootJar 不是为 Spring Boot 创建的
【发布时间】:2019-03-26 14:18:37
【问题描述】:

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

错误。但是当我添加 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 就会被创建。

【问题讨论】:

  • 看到这种行为是很正常的。插件管理不是激活任何插件,而是配置它们以防它们被激活。除非您在 pluginManagement 中配置的插件是标准插件,并且无论如何都是构建的一部分,否则如果没有明确声明任何插件,则该声明将没有任何效果。

标签: java spring maven spring-boot


【解决方案1】:

我的猜测是您只是将 &lt;plugins&gt; 标签包装在 &lt;pluginManagement&gt; 标签中,这并不能满足您的要求。我建议您阅读the documentation 以了解pluginpluginManagement 之间的关系。另见another post on StackOverflow

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

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

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

【讨论】:

    猜你喜欢
    • 2018-09-10
    • 2016-06-05
    • 2018-02-23
    • 2016-09-29
    • 2016-11-13
    • 2017-08-22
    • 2023-03-24
    • 2016-02-09
    • 1970-01-01
    相关资源
    最近更新 更多