Is it possible to configure dynamic route datasource by application.properties and JdbcTemplate ? I can use this stuff to configure simple datasource.
Thanks in advance for your help
You can't use multiple datasources only by configuration in application.properties.
You have to define multiple Datasources as bean like described here
http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-two-datasources
and than define new bean of type AbstractRoutingDataSource.
Is it possible to make Spring boot use my Beans.xml file?
How can I supply context to it?
Is there any other way to put it?
Sincerely,
Peter.
Absolutely! Just add a #Configuration with a #ImportResource. For more info, see http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/ImportResource.html
Is it possible to configure to DataSource configuration in spring xml and keep the resource mapping in hibernate configuration file.
You can find an example in the Spring reference (http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#orm-hibernate).
I migrate a Spring project from XML-based configuration to Java-based configuration.
What is the best way to migrate the following piece of configuration?
<aop:config expose-proxy="true" />
Hint: I use this setting to access the proxy in a bean so that a transactional method can be called from a method that is not transactional.
Hint: I have seen https://jira.spring.io/browse/SPR-8148 but I don't know whether the second of the recommended approaches is the right one.
There is a JIRA issue created for this as an improvement. I would suggest voting for it to get more chances to be prioritized better.
Is there a spring property to lazy-init all beans that spring framework loads ?
I know about these properties
- lazy-init="true"
- default-lazy-init="true"
however there are multiple spring config xml files and some are packaged within jar so dont have liberty to change neither <bean> nor <beans> tag.
Any other way to tackle this via configuration ? or programatically ?
Short of extending the Spring bean loader, none that I know of.
You caN also use #Lazy annotation, but it is the same as you mentioned above.
According to java doc this should work ( though it looks not nice)
if (context.getBeanFactory() instanceof DefaultListableBeanFactory)
{
((DefaultListableBeanFactory) context.getBeanFactory()).setAllowEagerClassLoading(false);
}
I've implemented this on my company, had to extend some classes of spring tough. It wasn't easy, but we gained about 20s on every tomcat startup. Unfortunately, for privacy clauses, I can't show the code, but take a look at ClassPathBeanDefinitionScanner,DefaultBeanDefinitionDocumentReader,ContextNamespaceHandler and ComponentScanBeanDefinitionParser classes.
Starting with Spring Boot 2 you can use the spring.main.lazy-initialization property to configure lazy initialization across the whole application.
Setting the property value to true means that all the beans in the application will use lazy initialization.
in application.yaml
spring:
main:
lazy-initialization: true
or in application.properties
spring.main.lazy-initialization=true