【发布时间】:2021-12-28 18:57:40
【问题描述】:
我得到了一个 spring-boot 项目,并被告知在 intellij 中运行它。我在intellij中打开了该项目。当我点击 gradle.build 文件时,我选择 run 并且项目编译。
预期:
当我在项目上单击运行时,我希望编辑器运行本地网络服务器并显示“Greetings from Greetings from ZprIng booTI, ${req.remoteAddr}”。鉴于ZitiSpringBootApplication.kt 是
/*
* Copyright (c) 2018-2021 NetFoundry Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openziti.sample.springboot
import org.openziti.springboot.ZitiTomcatCustomizer
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
import javax.servlet.http.HttpServletRequest
@SpringBootApplication(
scanBasePackageClasses = [
ZitiTomcatCustomizer::class,
HelloController::class
]
)
class ZitiSpringBootApplication
@RestController
class HelloController {
@GetMapping("/")
fun index(req: HttpServletRequest): String {
return "Greetings from ZprIng booTI, ${req.remoteAddr}"
}
}
实际
这是来自 intellij 的截图
如您所见,构建成功。如何从编辑器运行 Web 服务?任何帮助将不胜感激。
【问题讨论】:
-
您没有将项目正确导入 IDE。例如,没有为
src/main/kotlin目录设置源。确保您已导入项目的所有 Gradle 构建文件。见jetbrains.com/help/idea/gradle.html#link_gradle_project
标签: java spring spring-boot intellij-idea