Localhost отказался подключиться к Spring Boot Application с помощью Eclipse - PullRequest
0 голосов
/ 05 апреля 2019
 pom.xml file:


<?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>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>


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





    <properties>
        <java.version>1.8</java.version>
    </properties>






    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId> 
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</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>

Java-файл 1:

package springWaterProj;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication
public class DemoApplication {


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


}

Java-файл 2:

package springWaterProj;



import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class HelloController {


    @RequestMapping("/hello")
    public String sayHi() {
        return "hi"; 
    }
}

Ответы [ 2 ]

0 голосов
/ 06 апреля 2019

Решение 1: Завершить процесс

A simple solution is to terminate the process (in IDE) and clean and rebuild project.

Нажмите КРАСНУЮ кнопку, чтобы завершить процесс

Click on RED button to terminate process


Решение 2: Изменить порт

Change the port 
server.port=8088 # Server HTTP port.

Решение 3: уничтожить процесс с помощью cmd

netstat -ano | findstr :<yourPortNumber>
taskkill /PID <typeyourPIDhere> /F
0 голосов
/ 05 апреля 2019

Ваш вопрос не завершен.Если вы получаете сообщение об ошибке, как показано ниже, это означает, что порт 8080 уже используется.

The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.

В этом случае вы можете либо остановить приложение, работающее в этом порту, либо просто использовать другой порт.В вашем файле application.properties вы можете определить порт как

server.port=8181
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...