Relative Content

Tag Archive for javaspringspring-boot

Use dev and prod profiles in Spring Boot?

What must be done to configure profiles in Spring Boot 3.4.1? I have read on multiple sites (i.e. here) that there is a naming scheme with a default application.yml and if needed further files such as application-{profile}.yml. Setting the profile can be done in multiple variants, and one that seems reasonable is providing a command line parameter ./gradlew bootRun -Dspring.profiles.active={profile}.

How can I use a Request scope bean in a component and fall back to a default value outside of request scope?

I have 2 different classes, TenantContext, which is request scope, TenantIdentfierResolver which is a component. During Request Scopes, TenantIdentifierResolver should retrieve the Current tenant name from TenantContext, outside of request scopes, it should simply return default. (The tenant context will be set by the controller function in endpoints that require it). Here’s what that looks like.

How can I use a Request scope bean in a component and fall back to a default value outside of request scope?

I have 2 different classes, TenantContext, which is request scope, TenantIdentfierResolver which is a component. During Request Scopes, TenantIdentifierResolver should retrieve the Current tenant name from TenantContext, outside of request scopes, it should simply return default. (The tenant context will be set by the controller function in endpoints that require it). Here’s what that looks like.