【问题标题】:Unable to start EmbeddedWebApplicationContext - not a web app无法启动 EmbeddedWebApplicationContext - 不是 Web 应用程序
【发布时间】:2017-12-18 18:34:28
【问题描述】:

这里是 build.gradle 文件。我已经删除了 cmets 和敏感数据。 仍然收到“缺少 EmbeddedServletContainerFactory Bean”错误。

    buildscript {
    ext {
        springBootVersion = '1.5.9.RELEASE'
    }
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
        maven { url "https://plugins.gradle.org" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-
    plugin:${springBootVersion}")
        classpath("org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4")
        classpath("gradle.plugin.de.gliderpilot.gradle.semantic-
   release:gradle-semantic-release-plugin:1.3.1")
    }
    }
    dependencies { 
        compile('org.springframework.boot:spring-boot-starter-jdbc') 
        compile('org.springframework.boot:spring-boot-starter-mail') 
        compile('org.springframework.boot:spring-boot-starter-thymeleaf') 
    { 
                exclude module: 'spring-boot-starter-tomcat' 
        }             
        runtime files ('/libs/ojdbc8.jar') 
        testCompile('org.springframework.boot:spring-boot-starter-test') 
    }   
    plugins {
    id "org.sonarqube" version "2.5"
    id "com.gorylenko.gradle-git-properties" version "1.4.17"
    id "de.gliderpilot.semantic-release" version "1.3.1"
    }
    apply plugin: 'java'
    apply plugin: 'jacoco'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    apply plugin: 'idea'
    apply plugin: 'com.jfrog.artifactory'
    apply plugin: 'maven-publish'  
    sourceCompatibility = 1.8
    group = 'com.usps.informed-delivery'
    dependencies {
    compile('org.springframework.boot:spring-boot-starter-activemq')
    compile('org.springframework.boot:spring-boot-actuator-docs')
    compile('org.springframework.boot:spring-boot-starter-aop')
    compile('org.springframework.boot:spring-boot-starter-batch')
    compile('org.springframework.boot:spring-boot-starter-cache')
    compile('org.springframework.boot:spring-boot-starter-data-cassandra')
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-data-redis')
    compile('org.springframework.boot:spring-boot-starter-integration')
    compile('org.springframework.batch:spring-batch-integration')
    compile('org.springframework.integration:spring-integration-xml')
    compile('org.springframework.integration:spring-integration-mail')
    compile('org.springframework.integration:spring-integration-test')
    compile('org.slf4j:slf4j-api')
    compile('org.springframework.integration:spring-integration-java-dsl')
    compile("org.springframework:spring-oxm")
    compile("joda-time:joda-time")
    compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
    compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
    compile('org.liquibase:liquibase-core')
    compile('libs/ojdbc8.jar')
    runtime('org.springframework.boot:spring-boot-devtools')
    runtime('com.h2database:h2')    
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('org.springframework.batch:spring-batch-test')
    testCompile('org.springframework.integration:spring-integration-test') 
    }
    publishing {
    publications {
    mavenJava(MavenPublication) {
        from components.java
    }
    }
    }
    artifactory {
    contextUrl = 'http:whatever'
    publish {
    repository {
        if (version.toString().endsWith("-SNAPSHOT")) {
            repoKey = 'snapshots'
        } else {
            repoKey = 'releases'
        }
        username = "" 
        password = "" 
    }
    defaults {
        publications('mavenJava')
        publishArtifacts = true
        properties = ['qa.level': 'basic', 'dev.team': 'core']           
        publishPom = true
    }
    }
    resolve {
    repoKey = 'jcenter'
    username = "" 
    password = "" 
    }
    }
    sonarqube {
    properties {
    property "sonar.sourceEncoding", "UTF-8"
    property "sonar.projectKey", "readers-digest-generator"
    property "sonar.projectName", "Readers Digest Generator"
    }   
    }

根据请求发布 build.gradle 文件。我试图通过把 aplication.properties 文件中的 spring.main.web-environment-=false 和 BatchApplication.java 中的 app.setWebEnvironment(false)

【问题讨论】:

    标签: spring-boot spring-batch


    【解决方案1】:

    Spring Boot 假定它是一个 Web 应用程序,除非您另外配置它​​。文档(可在此处找到https://docs.spring.io/spring-boot/docs/current/reference/html/howto-spring-boot-application.html#howto-create-a-non-web-application)说明您可以通过调用SpringApplication#s setWebEnvironment(false) 或通过设置属性spring.main.web-environment=false 以编程方式将您的应用程序配置为不是Web 应用程序

    【讨论】:

    • 感谢米内拉先生! ...在“Pro Spring Batch”中爱你。等不及看电影了!我会尝试实施您的建议。
    • 你能发布你的构建文件吗?
    • 请停止添加 cmets 并更新您的问题。这是不可读的,所以我们真的无能为力。
    • 我什么都看不懂。您需要更新您的问题,以便我们为您提供帮助。
    • 好的。我已经使用 build.gradle 文件编辑了原始帖子。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-22
    • 2014-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-09
    • 2015-03-19
    相关资源
    最近更新 更多