Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin 如何实施";你好,世界&引用;在科特林的互联网上?_Kotlin - Fatal编程技术网

Kotlin 如何实施";你好,世界&引用;在科特林的互联网上?

Kotlin 如何实施";你好,世界&引用;在科特林的互联网上?,kotlin,Kotlin,我的包有以下文件 package com.example.hello_app.demo import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @RestController class Hello { @RequestMapping("/") fun index() :

我的包有以下文件

package com.example.hello_app.demo

import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class Hello {
        @RequestMapping("/")
        fun index() : String {
                return "Hello World"
        }
}
运行
gradle compileKotlin
时,我得到以下错误

Unresolved reference: web
Unresolved reference: web
Unresolved reference: RestController
Unresolved reference: RequestMapping
我错过了什么?
我是一个乞丐,所以我很困惑。

我想你失踪了,这里是

依赖关系

您正在使用项目中不可用的某些类。我想这是一个spring boot项目。如果您开始在一些
pom.xml
文件或一些
buil.gradle
文件中添加依赖项,效果会更好

下面是一个示例。如何将其添加到项目的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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>net.codejava</groupId>
    <artifactId>spring-boot-hello-world</artifactId>
    <version>1.0.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
    </parent>


    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build> 

</project>

4.0.0
net.codejava
或者看文档

请根据您的项目更改其他详细信息,如名称和包、id等