Maven:cvc-complex-type.2.4.a:发现无效的内容,以元素'plugin'开头

问题描述 投票:0回答:1

我对Maven pom.xml的配置不太满意。

对于Corda(区块链)Bootcamp示例,我正在尝试将Eclipse项目配置为与Java和Kotlin一起使用,但是我面临以下错误消息:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'plugin'. 
One of '{
    "http://maven.apache.org/POM/4.0.0":parent, 
    "http://maven.apache.org/POM/4.0.0":packaging, 
    "http://maven.apache.org/POM/4.0.0":name, 
    "http://maven.apache.org/POM/4.0.0":description, 
    "http://maven.apache.org/POM/4.0.0":url, 
    "http://maven.apache.org/POM/4.0.0":prerequisites, 
    "http://maven.apache.org/POM/4.0.0":issueManagement, 
    "http://maven.apache.org/POM/4.0.0":ciManagement, 
    "http://maven.apache.org/POM/4.0.0":inceptionYear, 
    "http://maven.apache.org/POM/4.0.0":mailingLists, 
    "http://maven.apache.org/POM/4.0.0":developers, 
    "http://maven.apache.org/POM/4.0.0":contributors, 
    "http://maven.apache.org/POM/4.0.0":licenses, 
    "http://maven.apache.org/POM/4.0.0":scm, 
    "http://maven.apache.org/POM/4.0.0":organization, 
    "http://maven.apache.org/POM/4.0.0":profiles, 
    "http://maven.apache.org/POM/4.0.0":modules, 
    "http://maven.apache.org/POM/4.0.0":repositories, 
    "http://maven.apache.org/POM/4.0.0":pluginRepositories, 
    "http://maven.apache.org/POM/4.0.0":dependencies, 
    "http://maven.apache.org/POM/4.0.0":reports, 
    "http://maven.apache.org/POM/4.0.0":reporting, 
    "http://maven.apache.org/POM/4.0.0":dependencyManagement, 
    "http://maven.apache.org/POM/4.0.0":distributionManagement
}' is expected.

这里是整个pom.xml内容

<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>r3</groupId>
    <artifactId>CordaAppBootCamp</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <java.version>1.8</java.version>
        <kotlin.version>1.2.51</kotlin.version>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-plugin</artifactId>
                    <version>${kotlin.version}</version>
                    <executions>
                        <execution>
                            <id>default-compile</id>
                            <phase>none</phase>
                        </execution>
                        <execution>
                            <id>default-testCompile</id>
                            <phase>none</phase>
                        </execution>
                        <execution>
                            <id>java-compile</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>java-test-compile</id>
                            <phase>test-compile</phase>
                            <goals>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
    </dependencies>

</project>

我在做什么错?

我在Baeldung的这篇文章中以这种方式做到了:

https://www.baeldung.com/kotlin-maven-java-project

它还有更多问题消息。我解决了其中一些问题,方法是使用<pluginManagement>标签

java eclipse maven kotlin corda
1个回答
0
投票

看一下Bootcamp cordapp的较新版本,gradle现在为您处理了所有这些,因此您无需自己担心依赖项。

https://github.com/corda/bootcamp-cordapp

作为另一注,推荐的IDE实际上是IntelliJ IDEA,不再黯然失色。 (来源:https://docs.corda.net/docs/corda-os/4.4/getting-set-up.html

© www.soinside.com 2019 - 2024. All rights reserved.