Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the Hypersistence banner when using hibernate-types-52 in Spring Boot?

I use the com.vladmihalcea:hibernate-types-52 dependency in my Spring Boot Project. And, I notice that on application boot, some large log messages were added:

2020-04-09 11:43:59.535  WARN 3465 --- [           main] Hypersistence Optimizer                  : You should use Hypersistence Optimizer to speed up your Hibernate application!
2020-04-09 11:43:59.535  WARN 3465 --- [           main] Hypersistence Optimizer                  : For more details, go to https://vladmihalcea.com/hypersistence-optimizer/
2020-04-09 11:43:59.536  INFO 3465 --- [           main] Hypersistence Optimizer                  : 
 _    _                           _     _
| |  | |                         (_)   | |
| |__| |_   _ _ __   ___ _ __ ___ _ ___| |_ ___ _ __   ___ ___
|  __  | | | | '_ \ / _ \ '__/ __| / __| __/ _ \ '_ \ / __/ _ \
| |  | | |_| | |_) |  __/ |  \__ \ \__ \ ||  __/ | | | (_|  __/
|_|  |_|\__, | .__/ \___|_|  |___/_|___/\__\___|_| |_|\___\___|
         __/ | |
        |___/|_|

           ____        _   _           _
          / __ \      | | (_)         (_)
         | |  | |_ __ | |_ _ _ __ ___  _ _______ _ __
         | |  | | '_ \| __| | '_ ` _ \| |_  / _ \ '__|
         | |__| | |_) | |_| | | | | | | |/ /  __/ |
          \____/| .__/ \__|_|_| |_| |_|_/___\___|_|
                | |
                |_|

The hint is nice and the project sounds actually interesting, but still want to have the banner removed from my application.

like image 472
Simulant Avatar asked Apr 09 '20 09:04

Simulant


2 Answers

There is a description by the Project Owner why the banner was introduced, why it will not be disabled on default and how to disable it manually.

How to remove the Hibernate Types banner

The automatic banner removal mode

In short, you can buy a Hypersistence Optimizer license and add the project as a dependency to benefit from the JPA and Hibernate auto-tuning checks.

Manual banner removal

Or you can add either a hibernate.properties or hibernate-types.properties file to your project with the one property to disable the banner:

hibernate.types.print.banner = false

Or, you could pass this property as a Java System property:

java -Dhibernate.types.print.banner=false -jar target/high-performance-java-persistence-1.0.0.jar

Spring Boot

Starting with the release of Hibernate 5.5 and the hibernate-types-55 dependency, you can now provide the hibernate.types.print.banner property in your application.properties file, like this:

spring.jpa.properties.hibernate.types.print.banner=false

If you're using hibernate-types-52 or older dependencies, then you won't be able to provide this setting via the Spring Boot application.properties file.

like image 57
Simulant Avatar answered Nov 19 '22 23:11

Simulant


An alternative to the answers above, if you do not have access to JVM arguments.

Both these approaches work with Spring Boot, tested on 2.2.x.

Option 1: additional properties file

Create a file at src/main/resources/hibernate-types.properties.

hibernate.types.print.banner=false

Option 2: hacking around the hibernate-types check

Create either of the following files (depending on your version of hibernate-types).

Latest way of doing things: src/main/java/io/hypersistence/optimizer/core/License.java.

package io.hypersistence.optimizer.core;

public class License {
  public static class Signature {
  }
}

An older version checks for src/main/java/io/hypersistence/optimizer/HypersistenceOptimizer.java.

package io.hypersistence.optimizer;

public class HypersistenceOptimizer {
}
like image 23
Jodiug Avatar answered Nov 20 '22 00:11

Jodiug