spring-mvc

NotReadablePropertyException: Invalid property 'moduleName' of bean class

江枫思渺然 提交于 2020-01-15 12:07:02
问题 I am getting the following exception in Spring MVC application: org.springframework.beans.NotReadablePropertyException: Invalid property 'moduleName' of bean class [java.lang.String]: Bean property 'moduleName' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:726) org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl

No JSON content (comes up null) from MockMvc Test using Spring MVC and Mockito

徘徊边缘 提交于 2020-01-15 12:00:51
问题 Have a codebase which uses SpringMVC 4.0.3.RELEASE for Restful Web Services. Codebase contains a fully functional Restful Web Service which I can verify works using postman and curl. However, when trying to write a unit test for the particular Restful Web Service using MockMvc, I become blocked with trying to obtain the JSON content from the unit test. Am wondering if its a config issue or an issue where I am not creating a fake object correctly (since this doesn't rely on tomcat and is

@WebMvcTest does not find buildProperties

六眼飞鱼酱① 提交于 2020-01-15 10:06:59
问题 I have working JUnit tests for my MVC controllers. Now I wanted to display the build number in the footer of every page, so I added the following div in my thymeleaf templates: <div class="versionInfo">Version <span th:text="${@buildProperties.getVersion()}"></span></div> Now the test fail with: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'buildProperties' available I tried to add it as a mock to no avail: @MockBean private BuildProperties

Why do I always get Whitelabel Error Page with status “404” while running a simple Spring Boot Application

牧云@^-^@ 提交于 2020-01-15 10:06:34
问题 My Controller @Controller //@RequestMapping("/") //@ComponentScan("com.spring") //@EnableAutoConfiguration public class HomeController { @Value("${framework.welcomeMessage}") private String message; @RequestMapping("/hello") String home(ModelMap model) { System.out.println("hittin the controller..."); model.addAttribute("welcomeMessage", "vsdfgfgd"); return "Hello World!"; } @RequestMapping(value = "/indexPage", method = RequestMethod.GET) String index(ModelMap model) { System.out.println(

Why do I always get Whitelabel Error Page with status “404” while running a simple Spring Boot Application

瘦欲@ 提交于 2020-01-15 10:06:27
问题 My Controller @Controller //@RequestMapping("/") //@ComponentScan("com.spring") //@EnableAutoConfiguration public class HomeController { @Value("${framework.welcomeMessage}") private String message; @RequestMapping("/hello") String home(ModelMap model) { System.out.println("hittin the controller..."); model.addAttribute("welcomeMessage", "vsdfgfgd"); return "Hello World!"; } @RequestMapping(value = "/indexPage", method = RequestMethod.GET) String index(ModelMap model) { System.out.println(

Passing JSON Array from javascript to spring mvc controller

独自空忆成欢 提交于 2020-01-15 09:06:25
问题 I am working on spring mvc and I need to pass JSON array to spring controller from my jsp using ajax. Can anyone help me out how to pass, map and access JSON array in controller. (JSON array would be like [{'Name':'ksjdfh','Email':'sdfkhg'},{'Name':'ksjdfh','Email':'sdfkhg'},{'Name':'ksjdfh','Email':'sdfkhg'}]) 回答1: There is a post on how to do that here: Parsing JSON in Spring MVC using Jackson JSON. Basically, you need a model object to deserialize the JSON to. Note that (as Gunslinger says

Spring boot repository does not save to the DB if called from scheduled job

ぐ巨炮叔叔 提交于 2020-01-15 08:52:07
问题 I have a spring boot application in which I need to schedule a job to read files from a specific directory and store the data into the DB. I used Spring batch for handling the files part as the number of files is very large. The application has a component named PraserStarer which has a method named startParsing . This method is annotated with @scheduled annotation. @scheduled(fixedDelay = 60 * 1000) public startParsing(){ // start spring batch job } I have a repository interface

Default JSON to Object mapping not working

一世执手 提交于 2020-01-15 08:45:42
问题 I would like to perform a POST of JSON message and want to do conversion to Employee Object. The JSON message is {"employee":{"id":2231,"name":"jeffarry2231","niNumber":"SN10KTL"}} . The Employee Object public class Employee { private Long id; private String name; private String niNumber; ... } The EmployeeController @Controller public class EmployeeController { @RequestMapping(value = "/employee/add/", method = RequestMethod.POST) public void addEmployee(Employee employee){ System.out

Cannot find class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactory] for bean with name 'sessionFactory'

空扰寡人 提交于 2020-01-15 08:40:50
问题 i created a project in spring using maven dependencies but i am getting the above mentioned error. i changed the version of hibernate dependency but stil it does nt get resolved here is the code: pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.shr<