使用Spring Native和 Gradle,通过bootBuildImageGradle 命令:
...
bootBuildImage {
builder = 'paketobuildpacks/builder:tiny'
environment = ['BP_NATIVE_IMAGE': 'true']
imageName = "demo-native"
}
...
Run Code Online (Sandbox Code Playgroud)
我可以创建一个 Docker 镜像。
我如何配置图像,例如添加HEALTHCHECK或修改ENTRYPOINT自定义配置,就像我在 Dockerfile 中所做的那样???
我目前正在开发一个 Spring Native 应用程序,它使用 paketo buildpack 进行构建并生成 Docker 映像。我想知道是否可以通过添加第三方工具(例如 Datadog 代理)来自定义生成的 Docker 映像。
另外,目前生成的容器镜像已安装在本地,是否可以直接将其发送到另一个 Docker 存储库中?
刚刚在https://start.spring.io/ Spring Boot 2.4.4 项目上生成,添加了 Spring Boot Native 0.9.1-SNAPSHOT
并且它无法在 IDEA 中启动(因此甚至还没有作为本机映像)
ApplicationContext 无法启动,因为找不到 Spring AOT 插件生成的“org.springframework.aot.StaticSpringFactories”。
满输出
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=52158:/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath ....
2021-03-20 22:07:21.264 ERROR 10192 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The ApplicationContext could not start as 'org.springframework.aot.StaticSpringFactories' that is generated by the Spring AOT plugin could not be found.
Action:
Review your local configuration and make sure that the Spring AOT plugin is configured properly.
If you're …Run Code Online (Sandbox Code Playgroud) 大家好,我是 GraalVM 的新手,正在尝试按照指南启动一个 spring 本机项目https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#getting-started-buildpacks。
当我添加plugins { id 'org.springframework.experimental.aot' version '0.11.0' }到 build.gradle 文件后尝试同步时,它失败并出现错误:
Plugin [id: 'io.spring.dependency-management', version: '1.0.11.RELEASE'] was not found in any of the following sources:
* Try:
Run with --scan to get full insights.
* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'io.spring.dependency-management', version: '1.0.11.RELEASE'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'io.spring.dependency-management:io.spring.dependency-management.gradle.plugin:1.0.11.RELEASE')
Searched in …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用最新的 SpringBoot 3 设置一个新应用程序,一切正常,直到我尝试使用本机编译创建和运行我的应用程序。仅供您参考,这是我在运行单元测试时收到的错误:
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `*****`: cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized
at [Source: (String)"[{"T":"success","msg":"authenticated"}]"; line: 1, column: 3] (through reference chain: java.util.ArrayList[0])
com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1909)
com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:408)
com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1349)
com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1417)
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:352)
Run Code Online (Sandbox Code Playgroud)
我正在尝试将 JSON 字符串转换为对象。当我将其作为常规 JAR 运行时它工作正常,但当我使用 Navite (GraalVM) 编译时它会失败。
女士们先生们大家好,
所以我只是想通过使用 Spring Native 为我的 Spring 应用程序获取可执行文件。
我的构建.gradle:
plugins {
id 'org.springframework.boot' version '2.5.4'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
id 'org.springframework.experimental.aot' version '0.10.3'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.5.4'
implementation 'org.springframework.boot:spring-boot-starter-web:2.5.4'
compileOnly 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.4'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.14'
implementation group: 'org.apache.poi', name: 'poi', version: '4.1.2'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
implementation …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行此处共享的非常基本的应用程序
我能够运行构建,但最终失败并出现以下错误:
[creator] Paketo BellSoft Liberica Buildpack 9.0.1
[creator] unable to find dependency
[creator] no valid dependencies for native-image-svm, 8.*, and io.paketo.stacks.tiny in [(jdk, 8.0.312, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 8.0.312, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 11.0.13, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 11.0.13, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (native-image-svm, 11.0.13, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 17.0.1, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 17.0.1, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (native-image-svm, 17.0.1, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *])]
[creator] ERROR: failed to build: exit status 1
Run Code Online (Sandbox Code Playgroud)
这是我的 build.gradle :
plugins {
id 'org.springframework.boot' version …Run Code Online (Sandbox Code Playgroud) 我找到了有关如何从 Spring Native Maven 项目运行 GraalVM 本机图像跟踪代理的信息,但我找不到有关如何从 Gradle 项目运行该操作的信息。
请参阅https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#_using_it_with_maven。
关于如何从 Gradle 项目中做到这一点有什么想法吗?