Maven错误:“不可解析的POM:Epilog中不允许使用开始标记”

时间:2019-04-23 20:21:50

标签: maven pom.xml

我正在使用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>

我对此并不陌生,似乎正在为这项工作绊脚石。我一直在关注微软网站上的教程。任何帮助将不胜感激。

提前感谢您的时间。

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分: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>