Should Spring Boot Data JPA automatically create EntityManagerFactory bean? I have added a table using Liquibase called Fred to my code, and now I wish to add JPA support for this. Upon adding: I get I understood that this bean should be created by spring. Can anyone explain when spring creates this bean for …
Tag: spring-boot
Fail to generate allure-results directory based on JUnit 4
I failed to generate the directory allure-results in my project. I have tried many methods from google(create src/test/resources/allure.properties, set <resultsDirectory>${project.build.directory}/allure-results</resultsDirectory> in pom.xml, etc.), but all setting seems not to take effect. I also…
How to write JUnit Test for uploading Image in Amazon S3 in Spring Boot
I have a problem about writing a test to upload Image in Amazon s3 in Spring Boot. I tried to write its test method but I got an error shown below. How can I fix it? Here is the method of Rest controller Here is the method of imageService. Here is the test method shown below. Here is the error
Spring jpa database connection for native query
I have a spring application that have to connect to a sql server db. There are no @Entity class and there ate no @Repository because the tables and the columns of the tables are unknown to the application. I have created a class and used an entity manager to execute queries, but I’m not sure this is the…
How to access configuration beans in Spring controllers
I have a Spring Boot application that uses Spring profiles to create environment specific configurations, for example: I have a @RestContoller that needs to access the values that the configurations load from application.properties. How can I inject the current environment specific configuration bean inside t…
delete where all keys of a map are contained in a list in mongodb
I have this: A field which is a map where the keys are UUIDs and the value another object which is not relevant. A list of UUIDs that should be passed as parameter. I want to: delete from the collection all documents where all keys of the map are included in the list of UUIDs The object: With derived queries
type=search_phase_execution_exception, reason=all shards failed when i send ‘/’
I’m using elasticSearch with RestHighLevelClient and Java. When I put query: QueryBuilder qb = new QueryStringQueryBuilder(“” + valueSearch.toLowerCase() + “”). Where valueSearch contain “/” -> example REC2/. The searchResponse = client.search(searchRequest, Reques…
are there any pitfalls when return @Entity from @RestController instead of DTO?
are there any pitfalls when return @Entity from @RestController instead of DTO ? like this: Answer I’d say yes. By returning an entity, you are going to have tight coupling of your response contract and the database entity. So in future if you want to make modifications to either your response/entity, y…
Is CSRF token require for Rest API in Spring boot
I am creating a Rest API using Spring boot on back-end and React js on frontend . I have a login form on React , should I enable csrf token on login/register form or not . After user logs in that user will get access token which I will store in memory in React and Refresh token in http only
while deploy in tomcat – No bean named ‘entityManagerFactory’ available
While deploying project to tomcat I got this error,but with sts ide all works perfectly. spoiled my 2days 🙁 . pom.xml Answer A version updation of hibernate worked for me!