问题描述
我正在尝试向我的jar的根级别添加.ebextensions文件夹,以将其部署到AWS Elastic beantalk.
I'm trying to add an .ebextensions folder to the root level of my jar to be deployed to AWS elastic beanstalk.
我的文件夹结构是:
main:
--src
--resources
--.ebextensions
构建jar时,我的.ebextensions
被放置在目标的类路径上,因此在部署时未被Elastic Beanstalk接收.
When I build the jar my .ebextensions
gets placed on the classpath of my target and therefore is not picked up by Elastic Beanstalk on deploy.
Pom.xml
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>false</addResources>
</configuration>
</plugin>
我该如何构建以使ELB吸收ebextensions?
How can I build so that ebextensions is picked up by ELB?
推荐答案
这对我有用,是我发现的最干净的解决方法:
This works for me, is the cleanest way (in maven) I found to solve this:
在项目的根目录中添加.ebextensions,并在插件"部分的末尾添加以下代码段:
Add .ebextensions in the root of your project and add this snippet at the end in the plugins section:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>prepare</id>
<phase>package</phase>
<configuration>
<tasks>
<unzip src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.directory}/${project.build.finalName}" />
<copy todir="${project.build.directory}/${project.build.finalName}/" overwrite="false">
<fileset dir="./" includes=".ebextensions/**"/>
</copy>
<zip compress="false" destfile="${project.build.directory}/${project.build.finalName}.jar" basedir="${project.build.directory}/${project.build.finalName}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
此插件使用ant解压缩由春季启动生成的最终jar,在根目录中复制.ebextensions并再次使用相同的名称压缩(jar).经过测试并在生产中工作:)
This plugin use ant to unzip the final jar generated by spring boot, copy the .ebextensions in the root and zip (jar) again with the same name. Tested and working in production :)
与Spring 1.5.3.RELEASE一起使用
Works with Spring 1.5.3.RELEASE
这篇关于春季靴和ebextensions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!