Mavenはコンパイルの失敗を返す:パッケージcom.mashape.unirest.httpは存在しません。

IceRevenge:

私は、依存関係Unirestをインストールするには、Mavenを使用しようとしました。私は、.jarファイル(ダウンロードunirest-javaの-1.4.9.jarを)そして、このようなPOMにこれを追加しました:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.mashape.unirest</groupId>
            <artifactId>unirest-java</artifactId>
            <version>1.4.9</version>
        </dependency>
    </dependencies>
</dependencyManagement>

また、私は、Eclipseでの.jarを追加しました: Eclipseの

今Mavenはパッケージが存在しないことを言います。Eclipseは、何かが間違っていたことを言いませんでした。私は間違って何をしたのですか?警告は、最初に問題がありますか?

マイログ:

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sap.cloud.sdk.sensorLive:sensorLive-application:war:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ com.sap.cloud.sdk.sensorLive:sensorLive:1.0-SNAPSHOT, C:\Users\c5283284\Documents\Projekte\Transformation module\sensorLive\pom.xml, line 52, column 21
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sap.cloud.sdk.sensorLive:sensorLive-unit-tests:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ com.sap.cloud.sdk.sensorLive:sensorLive:1.0-SNAPSHOT, C:\Users\c5283284\Documents\Projekte\Transformation module\sensorLive\pom.xml, line 52, column 21
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sap.cloud.sdk.sensorLive:sensorLive-integration-tests:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ com.sap.cloud.sdk.sensorLive:sensorLive:1.0-SNAPSHOT, C:\Users\c5283284\Documents\Projekte\Transformation module\sensorLive\pom.xml, line 52, column 21
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sap.cloud.sdk.sensorLive:sensorLive:pom:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 52, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] sensorLive - Root                                                  [pom]
[INFO] sensorLive - Application                                           [war]
[INFO] sensorLive - Unit Tests                                            [jar]
[INFO] sensorLive - Integration Tests                                     [jar]
[INFO]
[INFO] --------------< com.sap.cloud.sdk.sensorLive:sensorLive >---------------
[INFO] Building sensorLive - Root 1.0-SNAPSHOT                            [1/4]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (SAP S/4HANA Cloud SDK Project Structure Checks) @ sensorLive ---
[INFO]
[INFO] --------< com.sap.cloud.sdk.sensorLive:sensorLive-application >---------
[INFO] Building sensorLive - Application 1.0-SNAPSHOT                     [2/4]
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (SAP S/4HANA Cloud SDK Project Structure Checks) @ sensorLive-application ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sensorLive-application ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ sensorLive-application ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to C:\Users\c5283284\Documents\Projekte\Transformation module\sensorLive\application\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/c5283284/Documents/Projekte/Transformation module/sensorLive/application/src/main/java/com/sap/cloud/sdk/sensorLive/Servlet.java:[16,1] package com.mashape.unirest.http does not exist
[ERROR] /C:/Users/c5283284/Documents/Projekte/Transformation module/sensorLive/application/src/main/java/com/sap/cloud/sdk/sensorLive/Servlet.java:[17,32] package com.mashape.unirest.http does not exist
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for sensorLive - Root 1.0-SNAPSHOT:
[INFO]
[INFO] sensorLive - Root .................................. SUCCESS [  0.485 s]
[INFO] sensorLive - Application ........................... FAILURE [  2.233 s]
[INFO] sensorLive - Unit Tests ............................ SKIPPED
[INFO] sensorLive - Integration Tests ..................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.079 s
[INFO] Finished at: 2019-01-31T10:22:32+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project sensorLive-application: Compilation failure: Compilation failure:
[ERROR] /C:/Users/c5283284/Documents/Projekte/Transformation module/sensorLive/application/src/main/java/com/sap/cloud/sdk/sensorLive/Servlet.java:[16,1] package com.mashape.unirest.http does not exist
[ERROR] /C:/Users/c5283284/Documents/Projekte/Transformation module/sensorLive/application/src/main/java/com/sap/cloud/sdk/sensorLive/Servlet.java:[17,32] package com.mashape.unirest.http does not exist
[ERROR] -> [Help 1]
[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/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :sensorLive-application

マイ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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <name>sensorLive - Root</name>
    <description>sensorLive - Root</description>

    <groupId>com.sap.cloud.sdk.sensorLive</groupId>
    <artifactId>sensorLive</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.sap.cloud.s4hana</groupId>
                <artifactId>sdk-bom</artifactId>
                <version>2.9.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.mashape.unirest</groupId>
                <artifactId>unirest-java</artifactId>
                <version>1.4.9</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

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

        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <maven.compiler.testSource>${java.version}</maven.compiler.testSource>
        <maven.compiler.testTarget>${java.version}</maven.compiler.testTarget>

        <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <modules>
        <module>application</module>
        <module>unit-tests</module>
        <module>integration-tests</module>
    </modules>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.maventest.App</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.openejb.maven</groupId>
                <artifactId>tomee-maven-plugin</artifactId>
                <version>1.7.1</version>
                <configuration>
                    <tomeeVersion>1.7.1</tomeeVersion>
                    <tomeeClassifier>plus</tomeeClassifier>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M2</version>
                <executions>
                    <execution>
                        <id>SAP S/4HANA Cloud SDK Project Structure Checks</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>3.3.9</version>
                                </requireMavenVersion>
                                <requireJavaVersion>
                                    <version>${java.version}</version>
                                </requireJavaVersion>
                                <reactorModuleConvergence />
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

これは私がUnirestをインポートする方法です。

import com.mashape.unirest.http.*;
Watbub:

あなたはあなたに依存関係を追加しましたdependencyManagementあなたのポンポンのセクション。このセクションでは、依存関係が親ポンポンで定義されているが、子モジュールで使用することができ、マルチモジュールプロジェクトを対象としています。また、読書

(この場合のポンポンを、あなたはあなたの子供モジュールのPOMを開く必要があり、あなたの依存関係を使用できるようにするにはapplicationunit-testsまたはintegration-tests)、あなたがそうそこに好きな依存関係を使用したいというMavenの教え:

<?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/xsd/maven-4.0.0.xsd">

    ...

    <groupId>com.sap.cloud.sdk.sensorLive</groupId>
    <artifactId>application</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>com.mashape.unirest</groupId>
            <artifactId>unirest-java</artifactId>
        </dependency>
    </dependencies>

    ...

</project>

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=202766&siteId=1