执行spring-boot:在不继承spring-boot-starter-parent时运行

时间:2017-06-08 08:46:45

标签: java spring maven spring-boot pom.xml

我有一个spring-boot maven项目,由于组织限制,它不能将spring-boot-starter-parent作为父项。我遇到the following answer帮助我编译,测试和打包可执行jar。

但是当我尝试执行spring-boot:run时,我收到以下错误:

No plugin found for prefix 'spring-boot' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories

答案中的以下评论似乎指出要解决这个问题:

The code snippet above is sufficient to get the dependency management features. If you want plugins (like spring-boot:run) you need to confute those separately. You can copy paste from the Boot parent if you want

然而,在将建议的部分添加到我的pom文件后,我仍然得到相同的错误。我的pom文件可以在下面找到:

父pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>group.id.foo</groupId>
    <artifactId>foo_artifact</artifactId>
    <version>version_01</version>
    <packaging>pom</packaging>
    <name>${project.artifactId}</name>

    <prerequisites>
        <maven>2.2.1</maven>
    </prerequisites>

    <modules>
        <module>module_01</module>
    </modules>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <!--compilerArgument>-Dfile.encoding=ISO-8859-1</compilerArgument-->
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
                </configuration>
                <executions>
                    <execution>
                        <id>default</id>
                        <phase>compile</phase>
                        <configuration>
                            <source>1.8</source>
                            <target>1.8</target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.5.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.4</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

Child pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <properties>
        <java.version>1.8</java.version>
        <main.basedir>${basedir}/../..</main.basedir>
        <ing.continuous-delivery.version>00.04.04</ing.continuous-delivery.version>
        <maven.assembly.version>2.3</maven.assembly.version> 
    </properties>

    <parent>
        <groupId>group.id.foo</groupId>
        <artifactId>foo_artifact</artifactId>
        <version>version_01</version>
    </parent>

    <groupId>group.id.foo</groupId>
    <artifactId>${project.parent.artifactId}_app</artifactId>
    <version>${project.parent.version}</version>

     <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>1.5.3.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- tag::spring -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
            <version>1.5.3.RELEASE</version>
        </dependency>
        <!-- end::spring -->

        <!-- tag::web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>1.5.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-hateoas</artifactId>
            <version>1.5.3.RELEASE</version>
        </dependency>
        <!-- end::web -->
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <mainClass>${start-class}</mainClass>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.5.3.RELEASE</version>
            </plugin>
        </plugins>
    </build>
</project>

谢谢!

0 个答案:

没有答案