Home  >  Forum  >  Spring
Post New Query

Spring Boot application closes immediately



Asked on June 08, 2018
I am creating Spring Boot Application. When I start embedded server, it immediately shuts down.

pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.2.RELEASE</version>
</parent>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-openfeign</artifactId>
            <version>2.0.0.RC2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
    </dependency>
</dependencies>
<build>
  <plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
  </plugins>
</build>
<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/libs-milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

MyServerApplication.java

@SpringBootApplication
@EnableDiscoveryClient
@RestController
public class MyServerApplication {
@Autowired
DiscoveryClient client;

@RequestMapping("/")
public String hello() {
return "Hello World"; 
}

public static void main(String[] args) {
SpringApplication.run(HelloServerApplication.class, args);
}
}




Replied on June 08, 2018
You application is web application. So you need to use spring-boot-starter-web

Include below dependency in your pom.xml and test.

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



Replied on June 08, 2018
Thanks. It works.

Write Answer




©2019 concretepage.com | Privacy Policy | Contact Us