W. Marshall
W. Marshall

Reputation: 11

Spring Boot / REST - Sample Code Terminates After Launch

I am simply trying to run the sample code (via STS IDE as a Spring Boot App), but it simply terminates (and no errors occur). Downloaded from git, didn't modify.

Building a RESTful Web Service Sample Code : https://spring.io/guides/gs/rest-service/ Git Repo : git clone https://github.com/spring-guides/gs-rest-service.git

**Note : The one thing I tried, put [spring-boot-starter-tomcat] in my maven dependencies and downloaded, to no avail.

:: Spring Boot :: (v1.4.3.RELEASE)

2017-01-09 17:33:14.942 INFO 5548 --- [ main] hello.Application : Starting Application on TDL05100504 with PID 5548 (C:\wm_dev\gs-rest-service\complete\target\classes started by marshw2 in C:\wm_dev\gs-rest-service\complete) 2017-01-09 17:33:14.946 INFO 5548 --- [ main] hello.Application : No active profile set, falling back to default profiles: default 2017-01-09 17:33:15.043 INFO 5548 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6dc17b83: startup date [Mon Jan 09 17:33:15 EST 2017]; root of context hierarchy 2017-01-09 17:33:17.526 INFO 5548 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2017-01-09 17:33:17.553 INFO 5548 --- [
main] hello.Application : Started Application in 3.224 seconds (JVM running for 4.192) 2017-01-09 17:33:17.555 INFO 5548 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6dc17b83: startup date [Mon Jan 09 17:33:15 EST 2017]; root of context hierarchy 2017-01-09 17:33:17.559 INFO 5548 --- [ Thread-1] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown

Upvotes: 0

Views: 2716

Answers (3)

Mallikarjun Poojari
Mallikarjun Poojari

Reputation: 1

Change sample code as follow, it will work fine:

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

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

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

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

Upvotes: 0

W. Marshall
W. Marshall

Reputation: 11

For me, this problem was caused by corruption of my maven repository. Using STS 3.8.3, I was trying "Force Update of Snapshots/Releases" when doing Maven Update. This did not work. However, physically deleting the repo in File Explorer (and rebuilding) did do the job.

Upvotes: 0

lane.maxwell
lane.maxwell

Reputation: 5872

The project will run as is, so you shouldn't need to make any changes. Create a folder named resources under src/main. In that folder add a file called application.properties (or application.yml if you prefer yaml). Add a line to this file that will crank up the logging level to debug, you should get more details about what's going on.

src/main/resources/application.properties

logging.level.org.springframework=DEBUG

This is going to generate a LOT of information, but should spit out enough to show you what's up.

Upvotes: 0

Related Questions