Я пытаюсь сделать пример для службы REST из
https://spring.io/guides/gs/rest-service/
Я создал все 3 класса

Я делюсь кодом. Я видел другой вопрос, где была проблема с различными пакетами, но мои классы находятся в одном пакете.



После запуска программы я получаю следующий результат:

Я вижу, что консоль сообщает о прекращении, поэтому я не знаю, является ли это причиной того, что я не могу получить доступ к localhost: 8080 / приветствие, и я получаю, что сайт не может быть достигнут

Этот проект построен из Spring Tool 4, потому что в Eclipse я получаю сообщение об ошибке, когда пытаюсь выбрать из проектов «Импортировать содержимое Spring Start Started», но это вторая проблема.

Консоль выдает следующее:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.5.RELEASE)
2018-11-12 19:03:36.968 INFO 20324 --- [ main] hello.Application : Starting Application on ACL_GRE_PavlidisK with PID 20324 (C:\Users\KyriakosP\WorkSpaces\SpringTool\gs-consuming-rest-initial\target\classes started by KyriakosP in C:\Users\KyriakosP\WorkSpaces\SpringTool\gs-consuming-rest-initial)
2018-11-12 19:03:36.968 INFO 20324 --- [ main] hello.Application : No active profile set, falling back to default profiles: default
2018-11-12 19:03:37.015 INFO 20324 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@21a947fe: startup date [Mon Nov 12 19:03:37 CET 2018]; root of context hierarchy
2018-11-12 19:03:37.701 INFO 20324 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-11-12 19:03:37.705 INFO 20324 --- [ main] hello.Application : Started Application in 0.991 seconds (JVM running for 1.338)
2018-11-12 19:03:37.705 INFO 20324 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@21a947fe: startup date [Mon Nov 12 19:03:37 CET 2018]; root of context hierarchy
2018-11-12 19:03:37.705 INFO 20324 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-
plugin:2.0.5.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
baseName = 'gs-consuming-rest'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework:spring-web")
compile("com.fasterxml.jackson.core:jackson-databind")
testCompile("junit:junit")
}
Я не изменил файл Gradle. В руководстве нет ничего о файле Gradle
После вашего предложения добавить
compile("org.springframework.boot:spring-boot-starter-web")
в файле gradle, когда я запускаю приложение из IDE, программа завершается.
То же самое с maven из команды.
Только gradle (gradle bootRun) из командной строки работает и продолжает работать, поэтому браузер отвечает. ТАК ЧТО это убивает приложение в этих случаях?