Spring boot Gradle Spring引导:将根目录下的文件夹添加到jar

Spring boot Gradle Spring引导:将根目录下的文件夹添加到jar,spring-boot,gradle,intellij-idea,Spring Boot,Gradle,Intellij Idea,因此,我在spring boot项目的根目录下有一个文件夹.ebextensions,当我在gradle intellij插件中使用“bootpackage”时,这些文件没有包含在我的jar中。我正在Amazon Web服务上部署jar 如何将这些文件包括在我的jar中 我的身材,格雷德尔 buildscript { ext { springBootVersion = '1.5.9.RELEASE' } repositories { mavenCentral() } depend

因此,我在spring boot项目的根目录下有一个文件夹.ebextensions,当我在gradle intellij插件中使用“bootpackage”时,这些文件没有包含在我的jar中。我正在Amazon Web服务上部署jar 如何将这些文件包括在我的jar中

我的身材,格雷德尔

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}"
}
}
processResources {
from ('.ebextensions/') {
    into '.ebextensions'
}
}
解决方案: 将此添加到我的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}"
}
}
processResources {
from ('.ebextensions/') {
    into '.ebextensions'
}
}
我在项目源中添加了一个ebextensions文件夹,其中包含带有nginx config的.ebextensions文件夹:

文件夹结构

我扩展了bootJar任务:

bootJar {
   baseName = 'project'
   version = '1.0.0'
   from('ebextensions')
   //...
当我运行/gradlew-cle-ass-bootJar时,解压缩的项目-1.0.0.jar包含:

  • .ebextensions
  • BOOT-INF
  • META-INF
  • 组织机构
我用的是Gradle 4.10

根本原因是使用ElasticBeanstalk的413请求实体太大

proxy.conf的完整内容:

client_max_body_size 20M;

这看起来不错,但对我来说它不是根目录,而是在BOOT-INF\classes\for-meThis中。这对我来说很有效。非常感谢。