spring-mvc

Unable to save form data to database in spring mvc

时光毁灭记忆、已成空白 提交于 2020-05-31 01:25:20
问题 I am building a Spring MVC application where someone can fill up the form and if clicks Send then form data will save in database. I am using spring-data-jpa. But when I fill up the form and click send it shows HTTP Status 500 error. I followed every steps but its not working. Here is my Contact model, Contact service and Contact repository and the error ---> Error:::: HTTP Status 500 - Request processing failed; nested exception is org.springframework.dao

Unable to save form data to database in spring mvc

╄→гoц情女王★ 提交于 2020-05-31 01:24:41
问题 I am building a Spring MVC application where someone can fill up the form and if clicks Send then form data will save in database. I am using spring-data-jpa. But when I fill up the form and click send it shows HTTP Status 500 error. I followed every steps but its not working. Here is my Contact model, Contact service and Contact repository and the error ---> Error:::: HTTP Status 500 - Request processing failed; nested exception is org.springframework.dao

@Service and @Scope(“prototype”) together

倖福魔咒の 提交于 2020-05-29 14:29:58
问题 I have a service class with @Service and @Scope("protoype"). I want this service to behave like prototype in the controller class. Here is how I use it: @Controller @RequestMapping(value="/") public class LoginController { @Autowired private EmailService emailService; @RequestMapping(value = "/register", method = RequestMethod.POST) public String register(){ System.out.println(emailService); emailService.sendConfirmationKey(); } @RequestMapping(value = "/resetKey", method = RequestMethod.POST

@Service and @Scope(“prototype”) together

纵然是瞬间 提交于 2020-05-29 14:29:19
问题 I have a service class with @Service and @Scope("protoype"). I want this service to behave like prototype in the controller class. Here is how I use it: @Controller @RequestMapping(value="/") public class LoginController { @Autowired private EmailService emailService; @RequestMapping(value = "/register", method = RequestMethod.POST) public String register(){ System.out.println(emailService); emailService.sendConfirmationKey(); } @RequestMapping(value = "/resetKey", method = RequestMethod.POST

@Service and @Scope(“prototype”) together

天涯浪子 提交于 2020-05-29 14:28:51
问题 I have a service class with @Service and @Scope("protoype"). I want this service to behave like prototype in the controller class. Here is how I use it: @Controller @RequestMapping(value="/") public class LoginController { @Autowired private EmailService emailService; @RequestMapping(value = "/register", method = RequestMethod.POST) public String register(){ System.out.println(emailService); emailService.sendConfirmationKey(); } @RequestMapping(value = "/resetKey", method = RequestMethod.POST

Spring - Scheduled Task - Graceful Shutdown

我的未来我决定 提交于 2020-05-29 03:12:24
问题 I have a Spring-Boot application with a bean running a scheduled task at about 1 minute intervals, and this bean has a @PreDestroy method. Is there a solution for allowing a task which is currently being executed to complete - or at least given some time to complete - before the life cycle reaches the pre-destroy phase? 回答1: You need update configuration of ThreadPoolTaskScheduler . Set true for waitForJobsToCompleteOnShutdown (method setWaitForTasksToCompleteOnShutdown ). From documentation:

How to connect Two Database MySQL and MongoDB in the same project? Is it possible?

耗尽温柔 提交于 2020-05-28 06:02:15
问题 Currently I'm using Hibernate(MySQL) with Spring, the configuration is running fine for me, but once I configured another configuration mongo-config.xml file and trying to run a test case with mongodb it's showing Error creating bean with name .... from first configuration. Below is my mongo-config.xml <context:annotation-config /> <context:component-scan base-package="com.test.mongo" /> <context:property-placeholder location="classpath:mongo-dao.properties" /> <bean id="mongoTemplate" class=

How to connect Two Database MySQL and MongoDB in the same project? Is it possible?

大憨熊 提交于 2020-05-28 06:02:08
问题 Currently I'm using Hibernate(MySQL) with Spring, the configuration is running fine for me, but once I configured another configuration mongo-config.xml file and trying to run a test case with mongodb it's showing Error creating bean with name .... from first configuration. Below is my mongo-config.xml <context:annotation-config /> <context:component-scan base-package="com.test.mongo" /> <context:property-placeholder location="classpath:mongo-dao.properties" /> <bean id="mongoTemplate" class=

Spring Boot viewResolver not working - not mapping to given location

最后都变了- 提交于 2020-05-28 03:14:20
问题 I am developing spring boot application for learning. @Override public void configureViewResolvers(ViewResolverRegistry registry) { InternalResourceViewResolver resolver = new InternalResourceViewResolver(); resolver.setPrefix("/views/"); resolver.setSuffix(".jsp"); registry.viewResolver(resolver); } I have configured my view resolver as given above. And below is the API endpoint for page @RequestMapping(value = "/",method = RequestMethod.GET) public ModelAndView homePage(){ ModelAndView

Is NotNull needed on Kotlin?

假如想象 提交于 2020-05-27 05:34:27
问题 I have a class: class User( var name: String ) And a mapped post request: @PostMapping("/user") fun test(@Valid @RequestBody user: User) { //... } What if a client will send a JSON of a user with name: null ? Will it be rejected by the MVC Validator or an exception will be throwed? Should I annotate name with @NotNull ? Unfortunately, I cannot check that because only can write tests (it is not available to create User(null) ). 回答1: You can avoid using @NotNull , as it'll never get triggered