Spring Integration XML Configuration and Spring Boot Java Annotation Configuration - spring-boot

Is it possible to have spring integration xml configuration and spring boot java annotation configuration at the same time? Can you please refer with an example on this?
What is the best practice for this?
Thanks

As Marten pointed out it is fully fine to combine Spring Boot with an XML configuration. See Spring Boot docs: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using.configuration-classes.importing-xml-configuration
If you absolutely must use XML based configuration, we recommend that you still start with a #Configuration class. You can then use an #ImportResource annotation to load XML configuration files.
And here is the sample: https://github.com/spring-projects/spring-boot/blob/main/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/test/java/smoketest/xml/SampleSpringXmlPlaceholderBeanDefinitionTests.java

Related

How to migrate Spring Boot project to legacy Spring MVC project. Facing problem, how to read application.properties file in legacy Spring MVC project

I have done the POC in Spring Boot application. But our project is running on legacy Spring MVC.
The problem I am facing while converting Spring Boot project to Spring MVC, to read application.properties file.
The content of the Spring Boot application.properties file is as below
okta.oauth2.issuer=https://dev-3038103.okta.com/oauth2/bus3zhc6ayn7hfzQN5d6
resourceServer.url=http://localhost:8082
okta.oauth2.clientId={client-id}
okta.oauth2.clientSecret={secret-id}
okta.oauth2.scopes=openid,profile
server.port=8080
Can anyone please tell me how to handle?
There are many ways to achieve this,
Using PropertyPlaceholderConfigurer
Using PropertySource
Using ResourceBundleMessageSource
Using PropertiesFactoryBean
this is like a go to source.
Register PropertyPlaceholderConfigurer bean-
<context:property-placeholder location="classpath:path/filename.properties"/>
i am providing the implementation with first method however you can very easily about the rest, follow any one

aspectj annotation not working with flink [duplicate]

I am writing Spring 4 application with java config. I can use AOP in this project for all spring component. But i can't use it for a normal POJO class.
what is the library I need to add and what is the configuration I need to put in my config file to get this working
Spring AOP can only be applied to Spring-managed components/beans, not to non-Spring POJOs.
If you want to apply AOP to non-Spring classes you need AspectJ, not a proxy-based "AOP lite" framework like Spring AOP. For more information about how to use AspectJ (which does not need Spring at all) in combination with Spring and how to configure load-time weaving, please read the corresponding part of the Spring manual.

How Spring Boot autoconfigures the JCache when there is no JCache configuration file entry in spring.factories file?

I am new to spring boot project.
Currently I am working on a project with spring boot, Jcache with ehcache implementation.
I am trying to understand how spring boot autoconfigures the Cache Framework. I did my own research and identified spring boot #EnableAutoConfiguration reads the spring.factories file and autoconfigures the Cache related beans based on the classes available in classpath.
Here is the Spring Boot Cache auto configure Java based Configuration file available under spring.factories file
org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\
but for Jcache “ JCacheCacheConfiguration.java” is the Spring Boot auto configuration file , But this file is not available under spring.factroies file in autoconfigurer.jar file.
Then how spring boot auto configures the Jcache without entry in spring.factories file?
JCache implementations are providing a service (in META-INF). So Spring can found the implementation magically. The simpler is #EnableCaching which will find the provider and give you caching right away.
Then, you will want to provide a specific caching configuration. The easiest is by specifying spring.cache.jcache.config=ehcache.xml in your application.properties.
That's it. You will find a more complicated and Java (no xml) configuration in ehcache sample and pet clinic.

Is that possible to use ObjectDB in a Spring Boot application

I want to use ObjectDB in my Spring Boot application. How should I configure the application.yml file?
I don't want to add persistence.xml into my application. Is that possible?
You can follow this tutorial:
http://spring.io/guides/gs/accessing-data-jpa/
with adjustments to ObjectDB, as explained on this forum thread:
http://www.objectdb.com/database/forum/860

Basic interrogation about Spring boot and #EnableAutoConfiguration

I have a basic question about Spring Boot:
Say I am developping a websocket app. It seems the idea behind Spring Boot is as follows:
As a developer I am responsible for:
Including the following mvn dependency: spring-boot-starter-websocket
Annotate my configuration class with: #EnableAutoConfiguration
Spring Boot is then responsible for applying the following config: WebSocketAutoConfiguration
In a nutshell, is it how it works? Can someone please confirm of infirm the above?
You are absolutely correct.
After adding spring-boot-starter-websocket to your configuration file and using the #EnableAutoConfiguration annotation, Spring will use you class path to automatically determine which configuration settings and beans need to be created for you.
Spring Boot will handle the WebSocketAutoConfiguration and any other necessary common configurations.
More information can be found here: https://spring.io/guides/gs/spring-boot/

Resources