* refactor: Reorder tests without lambda Moves inner implementations of Answer and ArgumentMatcher to the top of the test classes. Also changes the lambda expression to a regular "pre java 8" expression in one of the tests. Resolves: BAEL-632 * feat: Create basic Monolithic JHipster project Commit just after creating a JHipster project, before making any modifications. Resolves: BAEL-137 * chore: Change the artifactId and name of the project From baeldung to jhipster-monolithic and JHipster Monolithic Application Relates to: BAEL-137 * feat: Create entities Post and Comment Relates to: BAEL-137 * feat: Fix Gatling configuration in pom.xml Relates to: BAEL-137 * feat: Add files for Continuous Integration Relates to: BAEL-137 * feat: Change pom.xml to conform to Baeldung standards - moved the <properties> element to the bottom of the file - excluded integration tests in the default surefire configuration - added a new profile, called integration, and added the integration tests there - added Java 8 in the <source> and <target> tags, under maven-compiler solves: BAEL-137 * chore: Add jhipster module to parent pom
49 lines
2.2 KiB
Java
49 lines
2.2 KiB
Java
package com.baeldung.config;
|
|
|
|
import io.github.jhipster.config.JHipsterProperties;
|
|
import org.ehcache.config.builders.CacheConfigurationBuilder;
|
|
import org.ehcache.config.builders.ResourcePoolsBuilder;
|
|
import org.ehcache.expiry.Duration;
|
|
import org.ehcache.expiry.Expirations;
|
|
import org.ehcache.jsr107.Eh107Configuration;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
|
import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
|
|
import org.springframework.cache.annotation.EnableCaching;
|
|
import org.springframework.context.annotation.*;
|
|
|
|
@Configuration
|
|
@EnableCaching
|
|
@AutoConfigureAfter(value = { MetricsConfiguration.class })
|
|
@AutoConfigureBefore(value = { WebConfigurer.class, DatabaseConfiguration.class })
|
|
public class CacheConfiguration {
|
|
|
|
private final javax.cache.configuration.Configuration<Object, Object> jcacheConfiguration;
|
|
|
|
public CacheConfiguration(JHipsterProperties jHipsterProperties) {
|
|
JHipsterProperties.Cache.Ehcache ehcache =
|
|
jHipsterProperties.getCache().getEhcache();
|
|
|
|
jcacheConfiguration = Eh107Configuration.fromEhcacheCacheConfiguration(
|
|
CacheConfigurationBuilder.newCacheConfigurationBuilder(Object.class, Object.class,
|
|
ResourcePoolsBuilder.heap(ehcache.getMaxEntries()))
|
|
.withExpiry(Expirations.timeToLiveExpiration(Duration.of(ehcache.getTimeToLiveSeconds(), TimeUnit.SECONDS)))
|
|
.build());
|
|
}
|
|
|
|
@Bean
|
|
public JCacheManagerCustomizer cacheManagerCustomizer() {
|
|
return cm -> {
|
|
cm.createCache(com.baeldung.domain.User.class.getName(), jcacheConfiguration);
|
|
cm.createCache(com.baeldung.domain.Authority.class.getName(), jcacheConfiguration);
|
|
cm.createCache(com.baeldung.domain.User.class.getName() + ".authorities", jcacheConfiguration);
|
|
cm.createCache(com.baeldung.domain.Post.class.getName(), jcacheConfiguration);
|
|
cm.createCache(com.baeldung.domain.Comment.class.getName(), jcacheConfiguration);
|
|
// jhipster-needle-ehcache-add-entry
|
|
};
|
|
}
|
|
}
|