Приложение Springboot сразу выходит - PullRequest
0 голосов
/ 27 ноября 2018

Когда я запускаю мое приложение spring boot, оно немедленно завершает работу (с exit code 0) с помощью:

 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.0.RELEASE)

2018-11-27 14:08:31.219  INFO 94920 --- [  restartedMain] c.springbootsecurity.jwt.JwtApplication  : Starting JwtApplication on 1000810002637M.local with PID 94920 (/Users/723305/Documents/spring/springbootSecure/target/classes started by 723305 in /Users/723305/Documents/spring/springbootSecure)
2018-11-27 14:08:31.222  INFO 94920 --- [  restartedMain] c.springbootsecurity.jwt.JwtApplication  : No active profile set, falling back to default profiles: default
2018-11-27 14:08:31.252  INFO 94920 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2018-11-27 14:08:31.722  INFO 94920 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2018-11-27 14:08:31.743  INFO 94920 --- [  restartedMain] c.springbootsecurity.jwt.JwtApplication  : Started JwtApplication in 0.752 seconds (JVM running for 1.294)

Process finished with exit code 0

моего 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.springbootSecurity</groupId>
    <artifactId>jwt</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>jwt</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.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-security</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

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

        </plugins>
    </build>        
</project>

Ответы [ 2 ]

0 голосов
/ 27 ноября 2018

Из-за того, что вы загрузились в pom.xml, вы не объявили стартовый веб-проект, он будет немедленно закрыт, это ожидаемое поведение, теперь для запуска в качестве веб-контейнера вам нужно добавить приведенный ниже код в ваш pom.xml.

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
0 голосов
/ 27 ноября 2018

Я не вижу проблем с этим.

Process finished with exit code 0

Это говорит о том, что процесс успешно завершен.

Если ваше приложение не имеет зависимости spring-boot-starter-web, то оно не будет запускать ни один сервер и не ожидать никаких запросов.

Это очень похоже на метод main, который неесть что выполнить или завершить, как только завершится основной код.

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