spring-mvc

Using PropertyOverrideConfigurer with Annotated Classes in Spring 3

寵の児 提交于 2020-01-23 07:41:14
问题 Edit : Here is some explanation of why the accepted answer works for me, and possibly what could be a problem for others. In my foo-app-servlet.xml, i have this line: <context:component-scan base-package="com.foo.app" /> When I used spring2 before, all my service beans came from applicationContext.xml, but now they are being brought in directly in the foo-app-servlet.xml. On my project servlets have their own set of overrides, so I need to override in the servlet override file instead of the

Spring Data Rest -Disable self links(HAL) in Json

泪湿孤枕 提交于 2020-01-23 07:05:07
问题 I am newbie to spring-data-rest. In my Application when i make a rest call i am getting json which consist on self-links and links to foreign key tables. But i want json instead on links. I generated my code using telosys tool generator. Here is my JSON what i am gettin when i made a REST call to the "merchandise" table in database.: { "id" : 1, "rate": 300, "type": "item", "shortDescription": "test", "longDescription": "test test", "_links": { "self": { "href": "http://localhost:8080

Spring validation @AssertTrue

爱⌒轻易说出口 提交于 2020-01-23 06:58:27
问题 How do I display on a view jsp validation error message that occurs as a result of @AssertTrue annotation? It isn't tied to a specific field, but I am using it to validate a combination of fields. If I use <form:errors path="*"/> that will display all the errors for that form? 回答1: From what I have tested it is important HOW you name your test function. And you should name it properly. You do not need field, getter or setter but your function HAVE TO start with 'is*' statement. fe.

Spring validation @AssertTrue

為{幸葍}努か 提交于 2020-01-23 06:58:24
问题 How do I display on a view jsp validation error message that occurs as a result of @AssertTrue annotation? It isn't tied to a specific field, but I am using it to validate a combination of fields. If I use <form:errors path="*"/> that will display all the errors for that form? 回答1: From what I have tested it is important HOW you name your test function. And you should name it properly. You do not need field, getter or setter but your function HAVE TO start with 'is*' statement. fe.

Using Velocity Tools with Spring 3.0.3

北战南征 提交于 2020-01-23 06:48:45
问题 When I update the bean: <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> <property name="cache" value="true"/> <property name="prefix" value=""/> <property name="suffix" value=".vm"/> <property name="toolboxConfigLocation" value="tools.xml" /> </bean> With the tools.xml path for Velocity Tools, I get: Caused by: java.lang.ClassNotFoundException: org.apache.velocity.tools.view.ToolboxManager I've tried plugging in tools version 2 and 1.4,

Using Velocity Tools with Spring 3.0.3

痴心易碎 提交于 2020-01-23 06:48:37
问题 When I update the bean: <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> <property name="cache" value="true"/> <property name="prefix" value=""/> <property name="suffix" value=".vm"/> <property name="toolboxConfigLocation" value="tools.xml" /> </bean> With the tools.xml path for Velocity Tools, I get: Caused by: java.lang.ClassNotFoundException: org.apache.velocity.tools.view.ToolboxManager I've tried plugging in tools version 2 and 1.4,

How to add bean configuration file in an eclipse-based Spring project?

萝らか妹 提交于 2020-01-23 06:23:22
问题 I started to work on a Spring project from scratch and while I was trying to add a new Spring bean configuration file, I just don't see it there. The project structure and the selection wizard is as following, Figure: No Spring section here in the selection wizard Figure: project structure How to add a bean configuration file in the project ? I tried to get a template and add in the project. However, I don't see the different tabs (such as, mvc, context etc ) in the file page. The maven

Spring Controller testing with MockMvc post method

南楼画角 提交于 2020-01-23 06:23:04
问题 I am trying to test a method of my controller in a Spring Boot application. This is a post endpoint, which gets an id in a request and it passes on this id to a service: @Slf4j @Controller public class AdministrationController { private final AdministrationService administrationService; @Autowired public AdministrationController(AdministrationService administrationService) { this.administrationService = administrationService; } @PostMapping("/administration") public @ResponseBody

Hibernate Soft Delete using update Cascade

感情迁移 提交于 2020-01-23 06:16:37
问题 In case I have 3 class which are connected each other. Room Class @Entity @Table(name="table_room") Class Room{ @Id @GeneratedValue @Column(name="id_room") private Integer id; @Column(name="name") private String name; @OneToMany(mappedBy="room") private List<Person> people; @Column(name="deleted") private int deleted; } Person Class @Entity @Table(name="table_person") Class Person{ @Id @GeneratedValue @Column(name="id_person") private Integer id; @Column(name="name") private String name;

How do I set the logging properties in a spring java configuration?

久未见 提交于 2020-01-23 03:23:05
问题 I am using a Spring 5 MVC application. I am trying to get a pure java configuration going. I notice that my logging is not working. I have this in my application.properties: logging.level.org.springframework.web=ERROR logging.level.org.springframework.security=ERROR logging.level.org.hibernate.SQL=DEBUG logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE Now I am not using application.properties of course, so how do I set this in a pure Java way in one of my @Configuration