Spring Boot无法启动HTTP侦听器

时间:2015-11-07 07:33:53

标签: spring-boot spring-boot-maven-plugin

当我启动Spring Boot应用程序jar时,我得不到关于HTTP端口上的服务侦听或任何错误。发布有点模糊的pom.xml和启动screencap:

<?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>**.***.****</groupId>
    <artifactId>***</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>


    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <slf4j.version>1.6.4</slf4j.version>
        <logback.version>1.0.1</logback.version>
        <libotp.version>0.1-SNAPSHOT</libotp.version>
        <apachecommons3.version>3.0.1</apachecommons3.version>
        <stormpath.version>1.0.RC5.1</stormpath.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>**.***.****</groupId>
            <artifactId>commons</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</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>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${logback.version}</version>
        </dependency>

        <dependency>
            <groupId>org.kamranzafar</groupId>
            <artifactId>libotp</artifactId>
            <version>${libotp.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${apachecommons3.version}</version>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.6.0</version>
        </dependency>

    </dependencies>

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


</project>

Application类是从start.spring.io

生成的标准类
@SpringBootApplication
public class Application {

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

Just this nothing else

2 个答案:

答案 0 :(得分:2)

我注意到你在属性部分引用了Stormpath版本。

这是你需要包含Spring Boot + Spring Security + Thymeleaf + Stormpath的最小pom(注意:这包括所有其他相关的Spring Boot启动器):

<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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>**.***.****</groupId>
    <artifactId>***</artifactId>
    <version>0.1.0</version>

    <dependencies>
        <dependency>
            <groupId>com.stormpath.spring</groupId>
            <artifactId>stormpath-default-spring-boot-starter</artifactId>
            <version>1.0.RC5.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                  <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

repackage上的spring-boot-maven-plugin目标为您提供了漂亮的超级罐。

完全披露:我为Stormpath工作。

答案 1 :(得分:1)

这是因为您的日志记录中存在配置错误。 水木清华。喜欢多个appenders左右。

尝试删除所有slf4jlogback依赖项。 这些将自动添加给您。

您之所以看到&#39;横幅是因为它通过std打印出来。 请参阅SpringApplication.java

中的this code