In my repository I’ve added the following method : Generated query by spring-data-mongo is : [debug] 2020-09-11 15:39:59,550 – o.s.d.m.c.MongoTemplate – find using query: { “eventDate” : { “$gt” : { “$date” : 1577833200000 }, “$lt” : { “$…
Tag: spring
How to pass data into spring batch ItemProcessor?
I have a CSV file that contains records of data (cases), for which I created a caseDTO object , however some of the properties of the caseDTO must be field from data included in the file name (every file must has a name with strict structure that contains some data). What i want to achieve is to pass the data
why does spring throw me an exception about bad sql code?
Im working in an app that has a spring boot server. the thing is that i have a query, not auto generated one, that throws me a bad sql exception and i cant seem to find out why. Also im using MySQL as a database this is my repository code : The one with the @Query annotation throws me: Can
How to modify tomcat web.xml location per webapplication
I’ve multiple spring boot applications deployed in my tomcat server (as war files). My problem is I want to customize tomcat’s default session-timeout for some of the webapps (ie. without editing the global $CATALINA_BASE/conf/web.xml). I searched and read tomcat docs. It seems the only way I can …
Spring choose property source by a combination of profiles
I have multiple environments driven by Spring profiles, such as application-int.yml, application-dev.yml etc with similar content: application-int.yml application-dev.yml My goal is to use the following property based on both the environment name and whether the mock profile is included: ws.endpoint from appl…
@StreamListener is not visible when outside main Application class of Spring Boot. What could be the reason?
This is Spring Cloud Stream application. As i mention in the title, the StreamListener annotation works when inside the SpringBootApplication main class, but not when it resides in a different class with @Component annotation. I believe it is some sort of StreamListener visibility issue. I am publishing messa…
using spring dependency injection for runtime generated dependencies
I am new to Spring and to better understand what I’m learning, I decide to integrate Spring into one of my projects. In the project, a collection of Events is generated at runtime, where Event is a POJO. FetcherA and FetcherB are two classes that depended on an Event instance to fetch their output, whic…
Spring bean properties of imported Jar are overridden by application bean definition
I have a class with same name in the imported jar file. The same class with the same properties also there in the jar file. I have given bean definition in my configuration file for the jar bean. But when the application started it is using the properties of my bean class instead of the properties defined for…
Internalization in Spring Boot Application
Sorry for my english. I am working on a spring boot application and I have the following situation. I implemented internalization and I created a following configuration class Also I have two properties files messages.properties and messages_us.properties. And I defined a User entity class like this: When I t…
Refactoring code that contains multiple if conditions
Here is some code I’ve written to save a UrlEntity : The above code exists in a service class and looks unnecessarily complex. I’m attempting to refactor so that the intent is clear. This is a basic refactoring I’ve written: This refactoring does not improve the code substantially. Is there …