Giter Site home page Giter Site logo

demo-profile-aot's Introduction

Purpose

The goal of this repository is to show what can be customized and what can not when using Spring profiles in Ahead-Of-Time transformations and native Spring Boot applications.

How to compile your native application

With Gradle:

./gradlew nativeCompile

or with Maven:

./mvnw -Pnative native:compile

How to run your native application

With Gradle, you can run the native application as follows:

build/native/nativeCompile/demo-profile-aot

With Maven:

target/demo-profile-aot

Which displays:

Default message from application.properties

How can I use an environment specific Spring profile like the prod one?

You should enable those profiles at build time since it involves changing the beans of the application context.

With Gradle, it is possible to do that with for example:

./gradlew processAot --args='--spring.profiles.active=prod' nativeCompile

With Maven, you can for example define a Maven profile that will enable the Spring Boot one with:

<profiles>
	<profile>
		<id>prod</id>
		<build>
			<pluginManagement>
				<plugins>
					<plugin>
						<groupId>org.springframework.boot</groupId>
						<artifactId>spring-boot-maven-plugin</artifactId>
						<configuration>
							<profiles>
								<profile>prod</profile>
							</profiles>
						</configuration>
					</plugin>
				</plugins>
			</pluginManagement>
		</build>
	</profile>
</profiles>

And when building the native executable or the container image, specify the profile with for example:

mvn -Pprod,native native:compile

When you compile your native executable like that, you get

Hello from prod
Default message from application.properties

What can you change at runtime with the same executable?

You can run the same application in debug mode by using the following command:

build/native/nativeCompile/demo-profile-aot --debug

You can customize the log level by using the following command:

build/native/nativeCompile/demo-profile-aot -Dlogging.level.org.springframework.beans.factory.support.DefaultListableBeanFactory=debug

You can enable the local profile since it does not involve changing the beans of the application context:

build/native/nativeCompile/demo-profile-aot -Dspring.profiles.active=local

Which displays:

Customized message from application-local.properties

You can also customize a configuration property value specifying directly the property value:

build/native/nativeCompile/demo-profile-aot -Dsample.message="Customized message from the command line"

Which displays:

Customized message from the command line

demo-profile-aot's People

Contributors

sdeleuze avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.