Java 在 WAR 中添加 .ebextensions 的位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18423932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 01:31:10  来源:igfitidea点击:

Where to add .ebextensions in a WAR?

javaamazon-web-servicesamazon-elastic-beanstalkwarebextensions

提问by flavian

Scenario:

设想:

  • AWS Elastic Beanstalk
  • Java application
  • .ebextensions currently placed in src/main/resources/.ebextensions
  • AWS 弹性豆茎
  • Java应用程序
  • .ebextensions 当前放置在 src/main/resources/.ebextensions

Commands are not being executed.

命令没有被执行。

Where is the .ebextensions supposed to go in a Java application?

.ebextensions 应该放在 Java 应用程序中的什么位置?

采纳答案by study

.ebextensions should be placed in the root of WAR.

.ebextensions 应该放在 WAR 的根目录中。

The WAR structure looks like the following:

WAR 结构如下所示:

web_app.war
          |
          |_.ebextensions
          |   |_ 01run.config
          |   |_ 02do.config
          |
          |_META-INF
          |
          |_WEB-INF
               |_ classes
               |_ lib
               |_ web.xml

Refer to the official AWS docsfor further information.

有关更多信息,请参阅官方 AWS文档

回答by Paul Taylor

Using Maven I did as follows:

使用 Maven 我做了如下:

  • mkdir src/main/ebextensions
  • put .config files into this folder
  • add the following to pom.xml

        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webResources>
                    <resource>
                        <directory>src/main/ebextensions</directory>
                        <targetPath>.ebextensions</targetPath>
                        <filtering>true</filtering>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
    
  • mkdir src/main/ebextensions
  • 将 .config 文件放入此文件夹
  • 将以下内容添加到 pom.xml

        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webResources>
                    <resource>
                        <directory>src/main/ebextensions</directory>
                        <targetPath>.ebextensions</targetPath>
                        <filtering>true</filtering>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
    

to transfer the files to the top level of the war when it is built.

在构建战争时将文件传输到战争的顶层。

回答by hertzi

Using gradle I did the following

使用 gradle 我做了以下

  • mkdir src/main/resources/ebextensions
  • put .config files into this folder
  • add the following to build.gradle
  • mkdir src/main/resources/ebextensions
  • 将 .config 文件放入此文件夹
  • 将以下内容添加到 build.gradle

apply plugin: 'war'

应用插件:'战争'

war {
    from('src/main/resources/ebextensions') {
        into('.ebextensions')
    }
}

to transfer the files to the top level of the war when it is built.

在构建战争时将文件传输到战争的顶层。

回答by user3654211

you missed resources, it works when I put the path right

你错过了资源,当我把路径正确时它会起作用

war {
    from('src/main/resources/ebextensions') {
        into('.ebextensions')
    }
}

回答by eold

Update for people here in 2020, now task name is "bootWar"

2020 年这里的人更新,现在任务名称是“bootWar”

bootWar {
    from('src/main/resources/ebextensions') {
        into('.ebextensions')
    }
}