spring-mvc

Add a Custom message for the Unique Constraints in hibernate

人走茶凉 提交于 2020-08-02 13:33:53
问题 @Entity @Table(name="users",uniqueConstraints = {@UniqueConstraint(columnNames = {"email"})}) public class User implements Serializable { @Column(unique = true,name = "email") @NotNull(message = "{NotNull.email}") @Email(message = "{Pattern.email}") @Size(min=10, max=50) private String email; public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } } I have the message.properties file which is working fine NotNull.email = Email is required Pattern

Add a Custom message for the Unique Constraints in hibernate

懵懂的女人 提交于 2020-08-02 13:32:27
问题 @Entity @Table(name="users",uniqueConstraints = {@UniqueConstraint(columnNames = {"email"})}) public class User implements Serializable { @Column(unique = true,name = "email") @NotNull(message = "{NotNull.email}") @Email(message = "{Pattern.email}") @Size(min=10, max=50) private String email; public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } } I have the message.properties file which is working fine NotNull.email = Email is required Pattern

Spring 3.5 how to add HttpSessionEventPublisher to my boot configuration

烂漫一生 提交于 2020-08-01 06:33:06
问题 I want to listen to session life cycle events. I read about adding <listener> <listener-class> org.springframework.security.web.session.HttpSessionEventPublisher </listener-class> </listener> to web.xml. But I don't have it. I am using class that extends SpringBootServletInitializer. How I can add this listener? 回答1: You can use ServletListenerRegistrationBean : @Bean public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() { return new

Add tenant dynamically in multitenant database application using Spring MVC and Hibernate

≡放荡痞女 提交于 2020-07-31 06:56:11
问题 i am developing web application which uses multitenant database configuration. I want to add tenant dynamically. I added master controller to create master schema which hold tenant record created dynamically. but problem is when i request to create tenant it went to MultitenantConnectionProvider i created database there but in database i want to scan package com.appointment.schedular.model.tenant and create table in ne database as well. Source code MasterDatabaseConfig.java @Configuration

How to map several segments of URL to one PathVariable in spring-mvc?

ぐ巨炮叔叔 提交于 2020-07-31 03:39:36
问题 I'm working on a webapp, one function of which was to list all the files under given path. I tried to map several segments of URL to one PathVariable like this : @RequestMapping("/list/{path}") public String listFilesUnderPath(@PathVariable String path, Model model) { //.... add the file list to the model return "list"; //the model name } It didn't work. When the request url was like /list/folder_a/folder_aa , RequestMappingHandlerMapping complained : "Did not find handler method for ..."

SpringBoot atomically convert integer to boolean with @RequestBody annotation? How can I reject integer to be converted to boolean?

ぐ巨炮叔叔 提交于 2020-07-30 15:30:09
问题 My request was an application/json type like this: {"able": true} , but when I send the request like this {"able":12345} , the field able still can get a correct value true . Why? @PatchMapping("/{id}/path/{name}") public ResponseEntity someMethod( @Valid @RequestBody SomeRequest request) { // do something } @Getter @Setter @NoArgsConstructor @AllArgsConstructor public class SomeRequest { @AssertTrue @NotNull private Boolean able; } 回答1: Because jackson.databind will parse int to bool when

Spring Boot app not serving static content

自闭症网瘾萝莉.ら 提交于 2020-07-28 13:03:31
问题 I am using Spring Boot, and am trying to make my static resources (CSS, JS, Fonts) available when deployed. The source code is available for you to look at or clone from https://github.com/joecracko/StaticResourceError. Right now my CSS, JS, and Font files are not visible to my deployed website. Here is my project directory structure: Here is the root directory of the compiled JAR: I assure you the files are present in their respective folders. Here is the network error I am seeing: And here

Not able to integrate liquibase with my spring boot project- getting error with many beans

我与影子孤独终老i 提交于 2020-07-28 05:03:31
问题 I am trying to add liquibase to my current project. Even after following all the necessary steps, I am getting the following error org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'profileController' defined in URL [jar:file:/C:/Users/if994410/.m2/repository/org/springframework/data/spring-data-rest-webmvc/3.3.0.RELEASE/spring-data-rest-webmvc- 3.3.0.RELEASE.jar!/org/springframework/data/rest/webmvc/ProfileController.class]: Unsatisfied

Not able to integrate liquibase with my spring boot project- getting error with many beans

谁说我不能喝 提交于 2020-07-28 05:01:26
问题 I am trying to add liquibase to my current project. Even after following all the necessary steps, I am getting the following error org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'profileController' defined in URL [jar:file:/C:/Users/if994410/.m2/repository/org/springframework/data/spring-data-rest-webmvc/3.3.0.RELEASE/spring-data-rest-webmvc- 3.3.0.RELEASE.jar!/org/springframework/data/rest/webmvc/ProfileController.class]: Unsatisfied

Not able to integrate liquibase with my spring boot project- getting error with many beans

梦想与她 提交于 2020-07-28 05:01:11
问题 I am trying to add liquibase to my current project. Even after following all the necessary steps, I am getting the following error org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'profileController' defined in URL [jar:file:/C:/Users/if994410/.m2/repository/org/springframework/data/spring-data-rest-webmvc/3.3.0.RELEASE/spring-data-rest-webmvc- 3.3.0.RELEASE.jar!/org/springframework/data/rest/webmvc/ProfileController.class]: Unsatisfied