Spring Boot 2 – Change Jar Name

archiveFileName is the new hotness. Everything else is deprecated. bootJar { archiveFileName = “${archiveBaseName.get()}.${archiveExtension.get()}” } or the Kotlin DSL equivalent: tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootJar>(“bootJar”) { this.archiveFileName.set(“${archiveBaseName.get()}.${archiveExtension.get()}”) } See: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:archiveName https://docs.gradle.org/current/userguide/lazy_configuration.html

Is Logback also affected by the Log4j zero-day vulnerability issue in Spring Boot? [closed]

From the Spring blog: Spring Boot users are only affected by this vulnerability if they have switched the default logging system to Log4J2. The log4j-to-slf4j and log4j-api jars that we include in spring-boot-starter-logging cannot be exploited on their own. Only applications using log4j-core and including user input in log messages are vulnerable. Useful explanation points: … Read more

Unable to use Keycloak in Spring Boot 2.1 due to duplicated Bean Registration httpSessionManager

This helped me to resolve an issue, remove @KeycloakConfiguration and use this instead (from KEYCLOAK-8725): Java: @Configuration @ComponentScan( basePackageClasses = KeycloakSecurityComponents.class, excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = “org.keycloak.adapters.springsecurity.management.HttpSessionManager”)) @EnableWebSecurity Kotlin: @Configuration @ComponentScan( basePackageClasses = [KeycloakSecurityComponents::class], excludeFilters = [ComponentScan.Filter(type = FilterType.REGEX, pattern = [“org.keycloak.adapters.springsecurity.management.HttpSessionManager”])] ) @EnableWebSecurity

How to configure RabbitMQ connection with spring-rabbit?

The application for that guide is a Spring Boot Application. Add a file application.properties to src/main/resources. You can then configure rabbitmq properties according to the Spring Boot Documentation – scroll down to the rabbitmq properties… … spring.rabbitmq.host=localhost # RabbitMQ host. … spring.rabbitmq.password= # Login to authenticate against the broker. spring.rabbitmq.port=5672 # RabbitMQ port. … spring.rabbitmq.username= … Read more

Is it possible to set a different specification per cache using caffeine in spring boot?

This is your only chance: @Bean public CaffeineCache cacheA() { return new CaffeineCache(“CACHE_A”, Caffeine.newBuilder() .expireAfterAccess(1, TimeUnit.DAYS) .build()); } @Bean public CaffeineCache cacheB() { return new CaffeineCache(“CACHE_B”, Caffeine.newBuilder() .expireAfterWrite(7, TimeUnit.DAYS) .recordStats() .build()); } Just expose your custom caches as beans. They are automatically added to the CaffeineCacheManager.

Spring Boot Actuator Health Returning DOWN

In your Spring properties, set endpoints.health.sensitive = false. The /health endpoint will then return the list of various health indicators and you can debug from there. For a production environment you should enable security around the /health endpoint. Edit As Vincent pointed out below, you’ll also need management.security.enabled = false if the health endpoint is … Read more

How to check two condition while using @ConditionalOnProperty or @ConditionalOnExpression

Since from the beginning of @ConditionalOnProperty it was possible to check more than one property. The name / value attribute is an array. @Configuration @ConditionalOnProperty({ “property1”, “property2” }) protected static class MultiplePropertiesRequiredConfiguration { @Bean public String foo() { return “foo”; } } For simple boolean properties with an AND check you don’t need a @ConditionalOnExpression.