spring-mvc

Does your handler implement a supported interface like Controller?

喜欢而已 提交于 2021-01-28 12:50:27
问题 After adding mvc:resource my application throwing error like "javax.servlet.ServletException: No adapter for handler [com.test.web.controller.AppController@190cf5c]: Does your handler implement a supported interface like Controller?" when i use below configuration it's workin fine, <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p=

Does your handler implement a supported interface like Controller?

早过忘川 提交于 2021-01-28 12:49:37
问题 After adding mvc:resource my application throwing error like "javax.servlet.ServletException: No adapter for handler [com.test.web.controller.AppController@190cf5c]: Does your handler implement a supported interface like Controller?" when i use below configuration it's workin fine, <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p=

Spring MVC: ResponseBodyAdvice doesn't get called for null response from controller

谁说胖子不能爱 提交于 2021-01-28 09:04:21
问题 I have a Spring boot REST API app. I have a use-case to add some common parameters to all API responses such as time and clientId . To achieve this, I am using a ResponseBodyAdvice to manipulate the output of controllers. However, if a controller returns null , the ResponseBodyAdvice doesn't get called. I have verified this by adding logs and breakpoints. My question is how do i overcome this behavior? Basically for cases when a controller returns null such a when no data exists, I still want

Testing non-blocking REST services with Spring MVC

梦想与她 提交于 2021-01-28 07:42:09
问题 I have a Spring MVC application . I want to test this controller: @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextConfiguration("classpath:backoffice-servlet.xml") public class TimeControllerTests { @Autowired private WebApplicationContext wac; private MockMvc mockMvc; @Before public void setup() { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); } @Test public void should_OK() throws Exception { mockMvc.perform(get("/time/2") .contentType(APPLICATION

can't serialize access for this transaction in spring batch

余生颓废 提交于 2021-01-28 06:46:55
问题 I am using Spring batch with spring boot for process my Csv file. When i run the application i am getting below error trace. 2018-08-27 16:23:35.694 INFO 12016 --- [nio-9004-exec-1] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: ORACLE 2018-08-27 16:23:36.025 INFO 12016 --- [nio-9004-exec-1] o.s.b.c.l.support.SimpleJobLauncher : No TaskExecutor has been set, defaulting to synchronous executor. 2018-08-27 16:23:36.898 INFO 12016 --- [nio-9004-exec-1] o

Spring Using SpEL Principal

好久不见. 提交于 2021-01-28 06:02:24
问题 I'm trying to use SpEL has in this document https://spring.io/blog/2014/07/15/spel-support-in-spring-data-jpa-query-definitions to do a query filtering results by the ?#{principal.id} The problem is that Spring returns an exception org.hibernate.QueryException: Not all named parameters have been set: [1] [select p , p.store, p.category from Product p JOIN p.store s JOIN p.category c WHERE p.store.id = :id AND p.keywords LIKE :keyword AND p.store.ownerId = ?1 ]; nested exception is java.lang

javax.persistence.RollbackException: Transaction marked as rollbackOnly

廉价感情. 提交于 2021-01-28 05:47:09
问题 I'm making a game with Spring MVC. I have a method for get the game and update but when it goes to update it gives an error, this is the code: HomeController.class @Transactional @RequestMapping(value = "/partida/{idPartida}", method = RequestMethod.GET) public String getPartida(@PathVariable("idPartida") long idPartida, Model model) throws IOException { Partida p = ServicioAplicacionPartida.getPartida(entityManager, idPartida); if (p.getJson() == null) { p.inicializarPartida(entityManager);

How do i write unit test for function with void return type

回眸只為那壹抹淺笑 提交于 2021-01-28 05:41:54
问题 I am new to writing Unit tests. I saw few examples of jUnit , but they all were for functions returning a value. I have to write unit test for following method. Also we are using objects and methods in this method not belonging to this class like ConfigParser and ParseConfig. How do i go about writing Unit tests for such menthods? @RequestMapping(value = "/generate-json" , consumes = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) @PageType(pageType = "PlaceHolderPageType")

QuerySyntaxException with enum

时光总嘲笑我的痴心妄想 提交于 2021-01-28 05:25:32
问题 I have a UserAssignmentRole class like this : @Data @Entity public class UserAssignmentRole { ... @Enumerated(EnumType.STRING) public Role role; } And the Role is enum, it looks like this: public enum Role{ admin, member, pending } Now when in my repository I try to query to select all with role of admin, it gives me error: @Query("select uar from UserAssignmentRole uar where uar.role=Role.admin") public List<UserAssignmentRole> listAdmin(Long userID, Long assignmentID); How this can be

spring post Failed to load resource: the server responded with a status of 400 (Bad Request)

Deadly 提交于 2021-01-28 05:15:26
问题 I'm trying to send a json object to a spring controller by using react fetch. But I'm getting following error. Failed to load resource: the server responded with a status of 400 (Bad Request) But get method can be called successfully. http://localhost:8080/test/xx/getSprintTasks/${this.props.sprintNo}` react fetch: fetch(`http://localhost:8080/test/xx/addSprintTasks/`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: task }) .then(response => { console.log(response) if