首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Gradle-在META-INF/spring.factory中找不到自动配置类

使用Gradle-在META-INF/spring.factory中找不到自动配置类
EN

Stack Overflow用户
提问于 2018-03-18 16:52:26
回答 1查看 7.1K关注 0票数 3

尝试将我在IntelliJ中使用gradle中的jar函数构建的jar部署到我的spring在本地运行良好,但没有将jar放在服务器上的linux server.Full上是错误的。

应用程序启动失败,org.springframework.beans.factory.BeanDefinitionStoreException:无法处理配置类haughton.icecreamapi.config.AppConfig的导入候选项;嵌套异常为java.lang.IllegalArgumentException:在META-INF/spring.Factory中找不到自动配置类。如果您使用的是自定义打包,请确保该文件是正确的。

我的build.gradle

代码语言:javascript
复制
group 'IceCreamApiCA1'
version '1.0-SNAPSHOT'
buildscript {

ext {
    springBootVersion = '1.5.9.RELEASE'
}
repositories{
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-
 plugin:${springBootVersion}")    }
 }

 // Apply the Spring Boot plugin
 //apply plugin: 'spring-boot'
 apply plugin: 'org.springframework.boot'
 // Apply the Java plugin (expects src/main/java to be source folder)
 apply plugin: 'java'

  // Specify the location where our dependencies will be found
repositories {
mavenCentral()
maven {
    url "http://repo.spring.io/milestone/"
}
}
jar{
baseName='IceCreamRestApi'
version='1.0.0'
manifest{
    attributes 'Main-Class': 'haughton.icecreamapi.Application'
}
from{
    configurations.compile.collect{ it.isDirectory() ? it : zipTree(it)}
}
}

 // Specify dependencies
dependencies {
compile 'org.hashids:hashids:1.0.1'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '1.5.2.RELEASE'

compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
compile 'org.springframework:spring-orm:4.3.7.RELEASE'
// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-aws-jdbc
// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-aws-context

compile 'org.apache.tomcat:tomcat-dbcp:8.0.30'

//compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity:3.0.2.RELEASE'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
 // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.8'

// https://mvnrepository.com/artifact/com.h2database/h2
compile group: 'com.h2database', name: 'h2', version: '1.4.196'

runtime 'javax.transaction:jta:1.1'
runtime 'org.aspectj:aspectjweaver:1.8.7'


 // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
 compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.8'
 testCompile 'org.springframework.boot:spring-boot-starter-test'

 }
EN

回答 1

Stack Overflow用户

发布于 2018-03-18 17:19:13

我认为你应该让spring-boot插件来创建可执行的jar (不要自己写)。默认情况下,此插件将在任务类路径的目录中搜索public static void main(String[])方法。如果您想指定自己,请使用bootJar任务。

代码语言:javascript
复制
bootJar {
    mainClassName = 'com.example.ExampleApplication'
}

https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/html/

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49346068

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档