Hello
I need to manage a bean (e.g. disable it from JConsole) in my project.
public static void main(String[] args) {
setSystemProperties(args);
SpringApplication springApplication = new SpringApplication(myMain.class);
springApplication.addListeners(new myWriter());
ApplicationContext context = new AnnotationConfigApplicationContext(myMain.class);
SingletonBeanRegistry beanRegistry = ((ConfigurableApplicationContext)context).getBeanFactory();
TestBean testBean = new TestBean();
beanRegistry.registerSingleton("TestBean", testBean);
springApplication.run(args);
}
I got the following exception from this line of code ApplicationContext context = new AnnotationConfigApplicationContext(myMain.class);
Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
Here is my YML file config settings.
jpa:
hibernate.ddl-auto: update
generate-ddl: true
properties:
hibernate:
cache:
use_second_level_cache: false
use_query_cache: false
generate_statistics: false
Please let me know how I could fix this issue. Thanks so much!