Spring Boot和ebextensions

s.p*_*ike 7 amazon-web-services maven amazon-elb spring-boot amazon-elastic-beanstalk

我正在尝试将.ebextensions文件夹添加到我的jar的根级别,以部署到AWS弹性beanstalk.

我的文件夹结构是:

main:
--src
--resources
  --.ebextensions
Run Code Online (Sandbox Code Playgroud)

当我构建jar时,我.ebextensions会被放置在目标的类路径上,因此在部署时不会被Elastic Beanstalk选中.

的pom.xml

<plugin>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-maven-plugin</artifactId>
     <configuration>
           <fork>true</fork>
           <addResources>false</addResources>
     </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我如何构建以便ELB获取ebextensions?

Jav*_*áiz 13

这对我有用,是我发现解决这个问题的最干净的方式(在maven中):

在项目的根目录中添加.ebextensions,并在插件部分的末尾添加此代码段:

<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>
Run Code Online (Sandbox Code Playgroud)

这个插件使用ant来解压弹簧引导生成的最后一个jar,再次使用相同的名称复制root和zip(jar)中的.ebextensions.经过测试并在生产中工作:)

适用于Spring 1.5.3.RELEASE


小智 2

我遇到了同样的问题,.ebextensions当我将它与直接将文件添加到所需目录相结合时,按照安迪的建议移动到罐子旁边对我有用,.conf如下所示:

/sf/answers/2870781231/