Maven错误:“不可解析的POM:在epilog中不允许启动标记”

问题描述 投票:-1回答:2

我正在使用Maven和Bing API为类项目创建Web搜索界面。通过命令提示符编译文件时,我收到一个奇怪的错误。

这是编译时的命令行结果:

C:\Users\zacha\Desktop\java-project>mvn compile exec:java
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM C:\Users\zacha\Desktop\java-project\pom.xml: start tag not allowed in epilog but got b (position: END_TAG seen ...</build>\r\n</project>\r\n<b... @46:3)  @ line 46, column 3
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project  (C:\Users\zacha\Desktop\java-project\pom.xml) has 1 error
[ERROR]     Non-parseable POM C:\Users\zacha\Desktop\java-project\pom.xml: start tag not allowed in epilog but got b (position: END_TAG seen ...</build>\r\n</project>\r\n<b... @46:3)  @ line 46, column 3 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

C:\Users\zacha\Desktop\java-project>

以下是我的POM文件:

<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.websearch.web</groupId>
  <artifactId>java-project</artifactId>
  <version>1</version>
  <name>New Project Using SchemaCrawler</name>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
      <version>2.3.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>us.fatehi</groupId>
      <artifactId>schemacrawler</artifactId>
      <version>${schemacrawler.version}</version>
    </dependency>
  </dependencies>  
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <schemacrawler.version>11.02.01</schemacrawler.version>
    <skip.signing.artifacts>true</skip.signing.artifacts>
  </properties>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>7</source>
          <target>7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
<build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.4.0</version>
        <configuration>
          <!--Your comment
            Replace the mainClass with the path to your java application.
            It should begin with com and doesn't require the .java extension.
            For example: com.bingwebsearch.app.BingWebSearchSample. This maps to
            The following directory structure:
            src/main/java/com/bingwebsearch/app/BingWebSearchSample.java.
          -->
          <mainClass>com.WebSearch</mainClass>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.0</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>attached</goal>
            </goals>
            <configuration>
              <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
              </descriptorRefs>
              <archive>
                <manifest>
                  <!--Your comment
                    Replace the mainClass with the path to your java application.
                    For example: com.bingwebsearch.app.BingWebSearchSample.java.
                    This maps to the following directory structure:
                    src/main/java/com/bingwebsearch/app/BingWebSearchSample.java.
                  -->
                  <mainClass>com.WebSearch.java</mainClass>
                </manifest>
              </archive>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>com.microsoft.azure</groupId>
      <artifactId>azure</artifactId>
      <version>1.9.0</version>
    </dependency>
    <dependency>
      <groupId>commons-net</groupId>
      <artifactId>commons-net</artifactId>
      <version>3.3</version>
    </dependency>
    <dependency>
      <groupId>com.microsoft.azure.cognitiveservices</groupId>
      <artifactId>azure-cognitiveservices-websearch</artifactId>
      <version>1.0.1</version>
    </dependency>
  </dependencies>

我是新手,似乎在这项任务中磕磕绊绊。我一直在关注微软网站的教程。任何帮助将不胜感激。

提前谢谢您的时间。

maven pom.xml
2个回答
0
投票

检查pom中'parent'标签的位置。它应该在'dependencies'结束标记之后。


0
投票

问题是你有多个根(顶级)元素,而XML必须只有一个。在POM中,根元素是<project>。所以你的其他顶级元素应该在<project>内移动。然后你应该将你的多个<build>元素合并为一个。

请详细了解XML并阅读POM reference,它会准确地告诉您每个元素可以包含哪些元素。尝试了解结构,然后您可以自己解决这些问题。使用IDE对您来说将是一个巨大的帮助,因为它在您编辑文件时指出了错误,并且它可能会提出一个解决方案。

您的最终POM结构应如下所示:

<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.websearch.web</groupId>
  <artifactId>java-project</artifactId>
  <version>1</version>
  <name>New Project Using SchemaCrawler</name>
  <dependencies>
    <dependency>...</dependency>
    <dependency>...</dependency>
    ...
  </dependencies>  
  <properties>
    ...
  </properties>
  <build>
    <plugins>
      <plugin>...</plugin>
      <plugin>...</plugin>
      ...
    </plugins>
  </build>
</project>
© www.soinside.com 2019 - 2024. All rights reserved.