首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Maven错误:“不可解析的POM: epilog中不允许开始标记”

Maven错误:“不可解析的POM: epilog中不允许开始标记”
EN

Stack Overflow用户
提问于 2019-04-24 04:21:50
回答 2查看 6.4K关注 0票数 0

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

以下是编译时的命令行结果:

代码语言:javascript
运行
复制
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文件:

代码语言:javascript
运行
复制
<?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>

我对此还是个新手,似乎在完成这项任务时步履蹒跚。我一直在关注微软网站上的一个教程。任何帮助都将不胜感激。

提前感谢您的宝贵时间。

EN

回答 2

Stack Overflow用户

发布于 2019-04-24 17:13:50

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

请学习更多关于XML的知识,并阅读POM reference,它确切地告诉您每个元素可以包含哪些元素。试着理解它的结构,然后你就可以自己解决这类问题了。使用IDE会对你有很大的帮助,因为它会在你编辑文件时指出错误,并可能提出解决方案。

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

代码语言:javascript
运行
复制
<?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>
票数 1
EN

Stack Overflow用户

发布于 2019-04-24 04:35:39

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55818857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档