0

我刚刚学习 Kotlin,我无法在我的 Maven 项目上安装库 Klaxon。GitHub:https ://github.com/cbeust/klaxon

我将设置从https://bintray.com/cbeust/maven/klaxon复制到 my pom.xml,但它不起作用。我尝试将其复制并粘贴到pom.xml

<!-- https://mvnrepository.com/artifact/com.beust/klaxon -->
<dependency>
    <groupId>com.beust</groupId>
    <artifactId>klaxon</artifactId>
    <version>4.0.2</version>
</dependency>

但它不起作用。

有人可以帮我安装这个库吗?或者只是给我一个链接以了解如何将任何库安装到我的 Maven 项目?我找不到这个信息,也许我不能写正确的谷歌搜索。

pom.xml:

<?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>FORMS</groupId>
<artifactId>FORMS</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Stemmer Stemmer</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <kotlin.version>1.3.21</kotlin.version>
    <kotlin.code.style>official</kotlin.code.style>
    <junit.version>4.12</junit.version>
</properties>

<profiles>
    <profile>
        <repositories>
            <repository>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>bintray-cbeust-maven</id>
                <name>bintray</name>
                <url>https://dl.bintray.com/cbeust/maven</url>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>bintray-cbeust-maven</id>
                <name>bintray-plugins</name>
                <url>https://dl.bintray.com/cbeust/maven</url>
            </pluginRepository>
        </pluginRepositories>
        <id>bintray</id>
    </profile>
</profiles>


<dependencies>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib</artifactId>
        <version>${kotlin.version}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.beust/klaxon -->
    <dependency>
        <groupId>com.beust</groupId>
        <artifactId>klaxon</artifactId>
        <version>5.0.5</version>
    </dependency>


    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-test-junit</artifactId>
        <version>${kotlin.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <sourceDirectory>src/main/kotlin</sourceDirectory>
    <testSourceDirectory>src/test/kotlin</testSourceDirectory>

    <plugins>
        <plugin>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-plugin</artifactId>
            <version>${kotlin.version}</version>
            <executions>
                <execution>
                    <id>compile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>test-compile</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

4

2 回答 2

1

依赖项必须在<dependencies>标签内。查看 Maven POM 的结构以了解更多信息。

https://maven.apache.org/pom.html

于 2019-03-17T13:09:40.350 回答
0

谢谢你的帮助!我的同志们帮助了我:由于 bintray.com 的政治,我不得不登录 bintray.com 并单击设置并将 settings.xml 下载到我的项目目录中的 pom.xml 中

于 2019-03-21T11:31:30.290 回答