heroku-buildpack-java:适用于Java应用程序的Heroku构建包

  • t2_345327
    了解作者
  • 231.7KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 08:17
    上传日期
适用于Java的Heroku buildpack 这是Java应用程序的官方构建包。 它使用Maven 3.6.2来构建您的应用程序,并使用OpenJDK 8来运行它。 但是,可以如下所述配置JDK版本。 这个怎么运作 如果构建包在其根目录中具有pom.xml文件或插件支持的其他POM格式之一,它将把您的应用程序检测为Java。 它将使用Maven执行pom.xml定义的构建并下载依赖项。 .m2文件夹(本地Maven存储库)将在构建之间缓存,以更快地解决依赖关系。 但是, mvn可执行文件和.m2文件夹在运行时都不会在您的.m2中提供。 文献资料 有关在Heroku上使用Java和buildpacks的更多信息,请参见以下Dev Center文章: 例子 配置 选择一个JDK 在项目目录的根目录中创建一个system.properties文件,并设置java.runtime.ve
heroku-buildpack-java-main.zip
内容介绍
Heroku buildpack for Java [![CircleCI](https://circleci.com/gh/heroku/heroku-buildpack-java/tree/main.svg?style=shield)](https://circleci.com/gh/heroku/heroku-buildpack-java/tree/main) ========================= ![java](https://cloud.githubusercontent.com/assets/871315/20325947/f3544014-ab43-11e6-9c51-8240ce161939.png) This is the official [Heroku buildpack](http://devcenter.heroku.com/articles/buildpack) for Java apps. It uses Maven 3.6.2 to build your application and OpenJDK 8 to run it. However, the JDK version can be configured as described below. ## How it works The buildpack will detect your app as Java if it has a `pom.xml` file, or one of the other POM formats supports by the [Maven Polyglot](https://github.com/takari/polyglot-maven) plugin, in its root directory. It will use Maven to execute the build defined by your `pom.xml` and download your dependencies. The `.m2` folder (local maven repository) will be cached between builds for faster dependency resolution. However neither the `mvn` executable nor the `.m2` folder will be available in your slug at runtime. ## Documentation For more information about using Java and buildpacks on Heroku, see these Dev Center articles: * [Heroku Java Support](https://devcenter.heroku.com/articles/java-support) * [Introduction to Heroku for Java Developers](https://devcenter.heroku.com/articles/intro-for-java-developers) * [Deploying Tomcat-based Java Web Applications with Webapp Runner](https://devcenter.heroku.com/articles/java-webapp-runner) * [Deploy a Java Web Application that launches with Jetty Runner](https://devcenter.heroku.com/articles/deploy-a-java-web-application-that-launches-with-jetty-runner) * [Using a Custom Maven Settings File](https://devcenter.heroku.com/articles/using-a-custom-maven-settings-xml) * [Using Grunt with Java and Maven to Automate JavaScript Tasks](https://devcenter.heroku.com/articles/using-grunt-with-java-and-maven-to-automate-javascript-tasks) ## Examples * [Tomcat Webapp-Runner Example](https://github.com/kissaten/webapp-runner-minimal) * [Spring Boot Example](https://github.com/kissaten/spring-boot-heroku-demo) ## Configuration ### Choose a JDK Create a `system.properties` file in the root of your project directory and set `java.runtime.version=1.8`. Example: $ ls Procfile pom.xml src $ echo "java.runtime.version=1.8" > system.properties $ git add system.properties && git commit -m "Java 8" $ git push heroku main ... -----> Java app detected -----> Installing OpenJDK 1.8... done -----> Installing Maven 3.3.3... done ... ### Choose a Maven Version You can define a specific version of Maven for Heroku to use by adding the [Maven Wrapper](https://github.com/takari/maven-wrapper) to your project. When this buildpack detects the presence of a `mvnw` script and a `.mvn` directory, it will run the Maven Wrapper instead of the default `mvn` command. If you need to override this, the `system.properties` file also allows for a `maven.version` entry (regardless of whether you specify a `java.runtime.version` entry). For example: ``` java.runtime.version=1.8 maven.version=3.3.9 ``` ### Customize Maven There are three config variables that can be used to customize the Maven execution: + `MAVEN_CUSTOM_GOALS`: set to `clean dependency:list install` by default + `MAVEN_CUSTOM_OPTS`: set to `-DskipTests` by default + `MAVEN_JAVA_OPTS`: set to `-Xmx1024m` by default These variables can be set like this: ```sh-session $ heroku config:set MAVEN_CUSTOM_GOALS="clean package" $ heroku config:set MAVEN_CUSTOM_OPTS="--update-snapshots -DskipTests=true" $ heroku config:set MAVEN_JAVA_OPTS="-Xss2g" ``` Other options are available for [defining a custom `settings.xml` file](https://devcenter.heroku.com/articles/using-a-custom-maven-settings-xml). ## Development To make changes to this buildpack, fork it on Github. Push up changes to your fork, then create a new Heroku app to test it, or configure an existing app to use your buildpack: ``` # Create a new Heroku app that uses your buildpack heroku create --buildpack <your-github-url> # Configure an existing Heroku app to use your buildpack heroku buildpacks:set <your-github-url> # You can also use a git branch! heroku buildpacks:set <your-github-url>#your-branch ``` For example if you want to have Maven available to use at runtime in your application, you can copy it from the cache directory to the build directory by adding the following lines to the compile script: for DIR in ".m2" ".maven" ; do cp -r $CACHE_DIR/$DIR $BUILD_DIR/$DIR done This will copy the local Maven repo and Maven binaries into your slug. Commit and push the changes to your buildpack to your GitHub fork, then push your sample app to Heroku to test. Once the push succeeds you should be able to run: $ heroku run bash and then: $ ls -al and you'll see the `.m2` and `.maven` directories are now present in your slug. ## Run Tests Locally Tests can be run and debugged locally by using the [Circle CI CLI](https://circleci.com/docs/2.0/local-cli/). For example, to run [Hatchet](https://github.com/heroku/hatchet) tests on `heroku-18` run: ``` $ circleci local execute --job hatchet-heroku-18 \ --env HEROKU_API_USER=$(heroku whoami) \ --env HEROKU_API_KEY=$(heroku auth:token) ``` Available jobs are defined in [.circleci/config.yml](.circleci/config.yml). ### Costs This command uses the credentials from your local `heroku` configuration. This means your account will be billed for any cost these tests incur. Proceed with caution. License ------- Licensed under the MIT License. See LICENSE file.
评论
    相关推荐
    • 缓存(依赖文件)
      缓存源码 此例子演示的是依赖文件的缓存 例子是一个xml文件
    • 易语言读入xml到高级表格
      易语言读入xml到高级表格源码,读入xml到高级表格,记录缓存
    • ehcahe页面缓存详细内容
      2.将ehcache.xml放入能加载到classpath中的任意包中,不能放入WEB-INF中(其详细配置参数代表含义已经注释) 3.在工程中web.xml配置过滤器 <filter-name>SimplePageCachingFilter <filter-class>...
    • parser-xml:解析器缓存兼容的 XML 解析器
      解析器缓存兼容的 XML 解析器。 安装 使用安装 npm i parser-xml --save 运行测试 npm test 用法 var parser = require ( 'parser-xml' ) ; 解析 parser . parse ( str , options , function ( err , res ) { if...
    • Xpath读取xml文件,实现文件缓存
      Xpath读取xml文件,实现文件缓存
    • xml编辑例子是一个关于网业缓存
      xml编辑例子是一个关于网业缓存的 例子比较详细
    • Zope XML Methods-开源
      ZopeXMLMethods提供了适用于XML / XSLT处理的Zope对象的方法。 XSLTMethod将XSLT转换器与XML文档相关联。 ZopeXMLMethods继承了XMLTransform。 它具有文件系统缓存功能,并且可以与许多XML / XSLT库一起使用。
    • 增加了从内存解析XML的tinyxml
      增加了从内存解析XML的tinyxml,添加了直接将缓存中的XML数据进行解析的接口和将XML数据写入到缓存的接口。
    • ehcache 缓存
      <?xml version="1.0" encoding="UTF-8"?>      maxElementsInMemory="10000" !-- 缓存最大数目 -->  eternal="false" !-- 缓存是否持久 -->  overflowToDisk="true" !-- 是否保存到磁盘,当系统当机时-->...
    • Mybatis延迟加载和缓存(基于XML配置).zip
      Mybatis延迟加载和缓存的相关配置和使用。案例中代码演示了使用步骤,包含详细注释)