Gradle Spring Boot:将root文件夹添加到jar

时间:2018-04-14 10:46:08

标签: spring-boot gradle intellij-idea

所以我在Spring启动项目的根目录下有一个.ebextensions文件夹,当我在我的gradle插件中使用“bootpackage”进行intellij时,这些文件没有包含在我的jar中。我正在Amazon Web上部署jar服务 如何在我的jar中包含这些文件?

我的build.gradle

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

apply plugin: 'java'
 apply plugin: 'eclipse'
 apply plugin: 'org.springframework.boot'

 group = 'haughton.daniel'
version = '0.0.1-SNAPSHOT'
  sourceCompatibility = 1.8

repositories {
mavenCentral()
}


ext {
springCloudVersion = 'Edgware.SR1'
}



 dependencies {
//compile 'org.springframework.cloud:spring-cloud-starter-aws'
compile('org.springframework.boot:spring-boot-starter-data-jpa')
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-mail
compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '2.0.0.RELEASE'

compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
// https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity4
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '2.1.2.RELEASE'

// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-aws-autoconfigure
//compile group: 'org.springframework.cloud', name: 'spring-cloud-aws-autoconfigure', version: '1.2.2.RELEASE'
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'


compile('org.springframework.boot:spring-boot-starter-web')
compile ('org.apache.tomcat:tomcat-dbcp:8.0.30')

runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}

dependencyManagement {
imports {
    mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

2 个答案:

答案 0 :(得分:2)

解决方案: 将此添加到我的build.gradle

processResources {
from ('.ebextensions/') {
    into '.ebextensions'
}
}

答案 1 :(得分:0)

我在项目源代码中添加了一个 ebextensions 文件夹,其中包含带有nginx配置的.ebextensions文件夹:

文件夹结构

enter image description here

我扩展了bootJar任务:

bootJar {
   baseName = 'project'
   version = '1.0.0'
   from('ebextensions')
   //...

当我运行 ./ gradlew驴asbootJar 时,解压缩后的 project-1.0.0.jar 包含:

  • .ebextensions
  • BOOT-INF
  • META-INF
  • org

我使用了Gradle 4.10。

根本原因是413请求实体因ElasticBeanstalk太大。

proxy.conf的全部内容:

client_max_body_size 20M;