I have built a User management service in which I’m using MongoDb (spring data). I have two models User and Role. Role model – and Role enumerator- In User there is a role attribute which I have @Dbref to role collection. My problem is that I want to have a option of using PostgreSql and MongoDb in the same application
Tag: spring-boot
Spring batch job runs automatically
I’m using a spring batch to read a CSV file and write it to the DB, using the controller trigger. On starting the application, before I hit from the browser url, I see the print statements from my reader, on the startup. Although it doesn’t print it for my processor or writer, which are in separate classes which I have
Dynamically update the @value annotated fields in spring
I am trying to dynamically update the @value annotated fields in my application. First of all, this application has a custom property source, with source being a Map<Object, String>. A timer is enabled to update the values after a minute interval. Initial values of source Map<String, Object> is supplied from the PropertySourceLocator. (This is not the real scenario, but I
How to use ElasticSearch JSON DSL in Java?
I’m working on a springboot project and having some trouble with ElasticSearch. The user will put some JSON-format elasticsearch DSL query strings in the database and they are black-box to me. What I need to do is get the query strings and use them so search information in elasticsearch. In python, the DSL can be a parameter like this: How
Spring JPA-I get error that object is not persisted even though i have persisted it
I am using Spring boot-I have 3 classes User,Role and UserRole.I have pesisted both role object and user object but i get error that role object is not persisted.The mappings- between User and UserRole is OneToMany ,between Role and UserRole OneToMany.In the UserServiceImpl class i have persisted Role object roleRepository.save(userRole.getRole()); Error is- Answer Couple of issues here. The first (and
Make Redis as optional
I am using spring boot with Redis.Redis is running as Docker container Redis is a memory DB, if it finds data in Redis based on the key, it retrieved from Redis otherwise go into actual db call. when Redis is running, code works fine. but sometimes for any reason, if Redis is down, I am getting exception RedisConnectionException: Unable to
Upload a file using Java 11 HttpClient to SpringBoot Server
My client upload method: My Spring Boot method that receives the file: The current error: What kind of headers can I add to ensure my Spring Boot server receives the file without errors? Answer MultipartException: Current request is not a multipart request This is telling you what’s wrong. In your code: .PUT(HttpRequest.BodyPublishers.ofFile(photo.toPath())), you are doing a PUT request with file’s
Failed to configure a DataSource: ‘url’ attribute is not specified using Spring Boot
this is a first time i am doing a simple spring boot crud i ran in to the problem with i don’t how to solve the problem I added in drivers correct way but I got the error pls solve this problem application.properties porm.xml Answer It seems that you failed to provide driver-class name. You can refer to : https://www.baeldung.com/spring-boot-failed-to-configure-data-source
Spring boot error in Application.java package
hello I just created a project in spring boot initializer but when I import the project in sts I have a set of errors that I do not understand the errors are : The type java.lang.Class cannot be resolved. It is indirectly referenced from required .class files Implicit super constructor Object() is undefined for default constructor. Must define an explicit
NoSuchBeanDefinitionException for NamedParameterJdbcTemplate in test class
I have a problem with running unit tests with JDBCTemplate in my spring boot application. I have the following code for configuration: and this is for repository class: that works by calling the Rest service from postman for example. I wrote this unit test to test only the repository part: but when i run the junit test i recive the