Spring application download completed at startup

I tried a simple spring boot application, it always shuts off automatically

 :: Spring Boot ::        (v1.4.1.RELEASE)
2016-10-23 13:05:21.681  INFO 16532 --- [           main] com.example.RestBootApplication          : No active profile set, falling back to default profiles: default
2016-10-23 13:05:21.766  INFO 16532 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6e20b53a: startup date [Sun Oct 23 13:05:21 EDT 2016]; root of context hierarchy
2016-10-23 13:05:23.682  INFO 16532 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-10-23 13:05:23.704  INFO 16532 --- [           main] com.example.RestBootApplication          : Started RestBootApplication in 2.632 seconds (JVM running for 5.168)
2016-10-23 13:05:23.705  INFO 16532 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6e20b53a: startup date [Sun Oct 23 13:05:21 EDT 2016]; root of context hierarchy
2016-10-23 13:05:23.708  INFO 16532 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>rest-boot</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </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</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

Main class

@SpringBootApplication
public class RestBootApplication {

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

controller

@Controller
public class HelloController {

    @RequestMapping("/hello")
    String helloWorld(){
        return "helloWorld";
    }

}

Trying to run in spring package. it always stops after starting up. I even added "spring-boot-starter-web" after looking at some questions with stackoverflow, but still encounters this problem.

Please, can you point out a problem to someone.

+4
source share
11 answers

This happened to me, and it turned out to be a corrupted maven apache repository.

To fix this, I deleted apache repo - on my Mac it was located in /Users/myname/.m2/repository/org/apache.

c:\users\myname.m2\repository\org\apache.

Maven - Update Project, , .

+6

, 8080 - .

, server.port=someAvailablePortNumber application.properties, "resources".

. , pom.xml, , maven (: , ..), . 8080 , tomcat (..: 8080), .

tomcat, . , :)

+1

-

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

tomcat:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <version>1.4.1.RELEASE</version>
</dependency>
0

Spring -Boot . , ,

mvn spring-boot:run

, , Github, . https://github.com/michaellihs/stackoverflow-40205600

, : Tomcat, 8080 - ( /).

0

  • POM.xml, .
  • spring-boot-starter-web , . , , Tomcat Maven, .

Dep

  1. application.properties application.yml, server.port=9081 maven mvn clean install spring-boot:run -e


    , .
0

, :

  • maven
  • maven install
  • spring

==== > , !

0

.m2 , . , .

0

tomcat . mvn .

[WARNING] /home/syam/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.23/tomcat-embed-core-8.5.23.jar; LOC ( )

, tomcat maven , .

0

8080 8083 application.properties, . server.port = 8083, .

0

.

mvn help:effective-pom , . , /, spring -boot.

0

maven

-1
source

Source: https://habr.com/ru/post/1658620/


All Articles