Issue
I was given a Spring Boot project and told to run it in IntelliJ. I have the project open in IntelliJ. When I click on the gradle.build file I select run and the project compiles.
Expected:
When I click run on the project I expected the editor to run a local webserver and display "Greetings from Greetings from ZprIng booTI, ${req.remoteAddr}". Given that the ZitiSpringBootApplication.kt
is
/*
* 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}"
}
}
Actual
Here is a screenshot from IntelliJ:
As you can see the build was successful. How do I run the web service from the editor?
Solution
I gave up trying to run this in IntelliJ. The other answer on this page doesn't make any sense. I ran the project from the command line using ./gradlew bootRun
.
Answered By - Evan Gertis
Answer Checked By - Cary Denson (JavaFixing Admin)