Skip to content
Advertisement

Tag: spring-mvc

Convert fields before sending to the page

I have a user dto class and i need to convert some of its properties before send it to frontend. UsedDto class Now, from my controller i get data like this In my case, before send data, i should convert boolean values (enabled, active) to string “Y” or “N”. How can i do this? Answer You can implement a custom

How to implement configuration to use oracle/postgreSQL dataSource with spring+mybatis framework?

Background: spring + mybatis + oracle data source Requirement: support postgreSQL data source exchange with minimum code change Example: Current: controllerA -> ServiceA -> daoA -> A.xml (oracle) Now need: we can configure use oracele/postgreSQL database source If configure use postgreSQL: controllerA -> ServiceA -> daoA -> A.xml (postgreSQL) More: Same controllerA、ServiceA for same business logic Differenct DaoA、A.xml for oracle

Spring Controller GET/POST/PUT to another interface

I am using React as frontend and Java Spring Boot as backend. React sends JSON form data as GET/PUT/POST requests to my backend url (http://localhost:8080/test). Now, I wan’t to send this JSON forward to another interfaces GET endpoint (https://another/interface/add?id={id}). This interface then queries database based on the id and answers 200 OK message with a JSON reply which I need

POST: Exception Status expected: but was:

Technically it should be a simple task, but I can’t find the error. I want to write a normal “POST method”, but when I tested it, it came to a problem: enter code here Status expected:<201> but what:<200>. My question is, why do I get an OK and not a CREATED? CODE: PostMapping in Controller Unit Test Answer Because for

Error creating entityManagerFactory.Unable building Hibernate SessionF.SchemaManagementException:Export identifier[new_user]encountered more than once

My controller class – My JpaRepository extended interface – My Pojo class – And , the errors which it is giving is – org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Export identifier [new_user] encountered

Advertisement