我在rasberry pi上创建了一个简单的Maven项目,并且我的项目连接到mysql数据库以便能够插入,因此要处理依赖项和插件,我有此pom.xml,但是当我尝试制作mvn软件包时,我有了在知道它是第一次工作并且可以很好地插入我的数据库中时出现以下错误,因此我尝试查看互联网上的几个示例,但均未获得结果。先感谢您

错误:


  [错误]插件org.apache.maven.plugins:maven-surefire-plugin:2.17或
  无法解决其依赖性之一:读取失败
  的工件描述符
  org.apache.maven.plugins:maven-surefire-plugin:jar:2.17:1问题
  在建立有效的模型时遇到
  org.apache.maven.plugins:maven-surefire-plugin:[未知版本]
  [错误] [致命]无法解析的POM
  /home/pi/.m2/repository/org/apache/apache/13/apache-13.pom:评论
  从第3行开始,第5列未关闭(位置:
  已看到START_DOCUMENT ... \ ufffd \ u63D \ ufffd \ u1 \ u4
  \ ufffd \ ufffd2 / \ ufffd \ ufffd7 \ ufffd / \ ufffd \ u00 \ ufffd \ ufffd \ u3 \ u0
  \ ufffd \ n \ u0 \ u0 \ ufffd \ u3 \ u0
  
  \ ufffd \ u0 \ u0 \ ufffd \ ufffd $ \ u40d \ ufffd \ ufffd \ ufffd \ ufffd \ ufffd \ ufffd \ u40 \ ufffd \ ufffd \ u3 \ u0 \ u13 \ ufffdI \ ufffd \ ufffd \ u1a \ u0 \ u0U \ ufffd \ ufffd \ ufffd \ u1au \ ufffd ...
  @ 81:40)由以下原因引起:java.io.EOFException:没有更多可用数据
  已看到START_DOCUMENT ... \ ufffd \ u63D \ ufffd \ u1 \ u4
  \ ufffd \ ufffd2 / \ ufffd \ ufffd7 \ ufffd / \ ufffd \ u00 \ ufffd \ ufffd \ u3 \ u0
  \ ufffd \ n \ u0 \ u0 \ ufffd \ u3 \ u0
  \ ufffd \ u0 \ u0 \ ufffd \ ufffd $ \ u40d \ ufffd \ ufffd \ ufffd \ ufffd \ ufffd \ ufffd \ u40 \ ufffd \ ufffd \ u3 \ u0 \ u13 \ ufffdI \ ufffd \ ufffd \ u1a \ u0 \ u0U \ ufffd \ ufffd \ ufffd \ u1au \ ufffd ...
  @ 81:40 @ /home/pi/.m2/repository/org/apache/apache/13/apache-13.pom,
  第81行,第40列


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>csRunBI</groupId>
    <artifactId>csRunBi</artifactId>
    <packaging>jar</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <url>http://maven.apache.org</url>

    <properties>
        <jodatime.version>2.5</jodatime.version>
        <log4j.version>1.2.17</log4j.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
            <type>maven-plugin</type>
        </dependency>
    </dependencies>

    <build>
        <finalName>csRunProject</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <!-- Jar file entry point -->
                            <addClasspath>true</addClasspath>
                            <mainClass>Main</mainClass>
                            <classpathPrefix>dependency-jars/</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.5.1</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <!-- exclude junit, we need runtime dependency only -->
                            <includeScope>runtime</includeScope>
                            <outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>

最佳答案

如果用jdk.version调用变量${jdk.version},则应在pom.xml中定义它。您可以像这样简单地在<properties>...</properties>标记之间添加新变量:

<properties>
    <jodatime.version>2.5</jodatime.version>
    <log4j.version>1.2.17</log4j.version>
    <jdk.version>1.8</jdk.version>
</properties>


您可以阅读有关pom属性的更多信息:pom properties documentation

09-03 18:55