Is there a way to enable yaml configuration (instead of properties file) in normal spring web mvc application without using spring boot and have the #Value annotation supported.
I searched a lot, everywhere it uses spring boot. I am not intrested to use spring boot, as its very heavy and have many dependancies configured for auto setup.
Any help would be appreciated......
Related
I'm using spring boot 2.1.1 version and use #EnableWebFlux but I got some errors.
Errors are
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.reactive.config.DelegatingWebFluxConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalStateException: The Java/XML config for Spring MVC and Spring WebFlux cannot both be enabled, e.g. via #EnableWebMvc and #EnableWebFlux, in the same application
How can I fix this problem.
You can't have both Spring MVC and Spring WebFlux enabled in Spring SPR-16609
enabling MVC and WebFlux in the same application context which triggers a conflict
you can't have them in the same process currently.
It offers a workaround to use use reactive repositories:
However, you can use reactive repositories from your existing Spring MVC application, and return the reactive types (Flux or Mono), from Spring MVC controller methods.
Based on Spring Docs and SpringFramework Collaborator Juergen Hoeller, you can have both Spring MVC and Spring WebFlux present in the same app. In this way, you are using Spring MVC by default, while you can have reactively enabled endpoints at the same time. Keep in mind, it is essentially a servlet-based MVC app you are using.
If you also have #EnableWebFlux on top of that, you mean that you wish to strictly turn this into a reactive web application.
My suggestion is to turn off #EnableWebFlux and keep your application straightly MVC-based. You can still use some of the reactive features such as Mono<> and Flux<> by importing Webflux dependencies.
I was facing the same issue as using io.springfox with Spring-WebFlux.
I changed to use springdoc and solved the issue: https://springdoc.org/#migrating-from-springfox
For sample detail you can check in this: https://github.com/mnguyencntt/springboot-webflux-swagger
Does anyone know what should be correct spring boot properties to fine tune queryService in couchbase client. I am using spring-boot-starter-data-couchbase-reactive which uses couchbase-java-client 2.5.9 and couchbase-core-io 1.5.9
I am trying below properties but it is not working.
spring.couchbase.env.endpoints.queryservice.min-endpoints=5
spring.couchbase.env.endpoints.queryservice.max-endpoints=10
spring.couchbase.env.autorelease-after=5000
I can extend AbstractCouchbaseConfiguration to override properties but I would like to know if it is possible using spring boot properties.
I want to develop my springboot configuration module.
For example, I want to the behaviors of serialization and deserializion consistent in the Spring ConverterSPI and JsonHttpMessageConverter/XmlHttpMessageConverter.
So,i try to register all converters in Spring ConverterSPI to global configuration JsonHttpMessageConverter/XmlHttpMessageConverter provides.
And decide whether to open by configuration.
For this spring-boot configuration module, I don't want to rely on the spring-boot version.
Otherwise, the actual spring-boot project needs to exclusion the transitive dependencies spring boot when introducing this module.
How to achieve this goal?
I am developing an application that runs on Spring Boot configured via XML. For modularity, I didn't want to use #ImportResource as it requires me to go into the source code when in XML configuration I can just configure the XML files to change dependencies.
The problem is that I'm using Spring Boot to run my Spring MVC Controllers (#Controller) and for me to make use of the dependencies I configured in my XML files, I need to declare #ImportResource, which I don't want to use.
Is there any workaround to not use #ImportResource while still using XML config files to inject the dependencies in my Spring MVC Controllers?
If you are using spring boot and you are ok with mentioning the config location in application properties, you can do this in application.properties
config:
location: file:///config.xml
And the you can use this property in your #ImportResource
#ImportResource("${config.location}")
This way you can avoid changes to the source code, while still using xml configuration.
What's the best method to initiate a new Spring Project ?
Initiating Spring project is a lot of pain with various xml and db configuration.
Is there an "official" repository with complete sample project, as MVC with db access and so ?
Spring Boot may also be the solution, but some point still not clear to me :
How to add external components (such as Quartz) without creating some xml config ? (No such xml in Boot apparently)
Is a Spring Boot builded app is production-proof ?
As writen in the comments http://start.spring.io/ is the best way to start Spring boot project(STS has integration for it).
If you want to use something that is not supported by Spring Boot you can init spring beans the same way you do it in xml, just use java configuration. See this for example: http://www.tutorialspoint.com/spring/spring_java_based_configuration.htm
Also useing xml is still available. You can add #ImportResource on your Configuration class
#EnableAutoConfiguration
#Configuration
#ImportResource({"classpath*:applicationContext.xml"})