spring-mvc

How to configure controller in spring without component scanning in xml?

情到浓时终转凉″ 提交于 2020-01-23 13:52:10
问题 I have to design a very large scale project for a bank using spring mvc. I already choose to go with the XML configuration. My concern is to limit the start up time of the server. There will be approximately 2000 controllers. I already use component scan for scanning the @Controller . It worked fine. But, the problem is when I remove the component scan from XML and add the controller bean using bean configuration manually in XML, it didn't create the instance of controller in IOC container.

How to configure controller in spring without component scanning in xml?

放肆的年华 提交于 2020-01-23 13:51:51
问题 I have to design a very large scale project for a bank using spring mvc. I already choose to go with the XML configuration. My concern is to limit the start up time of the server. There will be approximately 2000 controllers. I already use component scan for scanning the @Controller . It worked fine. But, the problem is when I remove the component scan from XML and add the controller bean using bean configuration manually in XML, it didn't create the instance of controller in IOC container.

Spring can't create beans

烂漫一生 提交于 2020-01-23 13:49:27
问题 Hello everyone I'm getting an exception while develeping a web application with spring mvc and hibernate, the problem is that spring don't know my beans Controller @Autowired public PersonneMetierImpl personneMetier; @RequestMapping(value = "/test", method = RequestMethod.GET) public String test(Locale locale, Model model) { personneMetier.ajouterPersonne(new Personne("azrou", "zakaria.bariki@gmail.com", "bariki", "zakaria", "0641057217")); return "test"; } DAO classe @Repository public class

Spring can't create beans

一笑奈何 提交于 2020-01-23 13:48:27
问题 Hello everyone I'm getting an exception while develeping a web application with spring mvc and hibernate, the problem is that spring don't know my beans Controller @Autowired public PersonneMetierImpl personneMetier; @RequestMapping(value = "/test", method = RequestMethod.GET) public String test(Locale locale, Model model) { personneMetier.ajouterPersonne(new Personne("azrou", "zakaria.bariki@gmail.com", "bariki", "zakaria", "0641057217")); return "test"; } DAO classe @Repository public class

Routing multiple URLs to Spring Boot Actuator's health endpoint

删除回忆录丶 提交于 2020-01-23 13:04:18
问题 I have an app configured to serve Spring Boot Actuator's health endpoint at /manage/health. Unfortunately due to some details of the infrastructure I'm deploying to I need to alias both / and /health over to /manage/health. I don't see an option to customize just the health endpoint URL via properties. I'm assuming there's no way to add extra @RequestMapping annotations that apply to a controller I don't own. I'd prefer to explicitly define the required aliases as opposed to some traffic

How to make Spring Controller to return CSV from a POJO? [duplicate]

风格不统一 提交于 2020-01-23 10:46:08
问题 This question already has answers here : Configuring Spring MVC controller to send file to client (2 answers) Closed 5 years ago . Given a simple Java Object: public class Pojo { private String x; private String y; private String z; //... getters/setters ... } Is there some lib that i can put on my project that will make a controller like this: @RequestMapping(value="/csv", method=RequestMethod.GET, produces= MediaType.TEXT_PLAIN) @ResponseBody public List<Pojo> csv() { //Some code to get a

How to change ErrorAttributes of ResponseStatusException?

六眼飞鱼酱① 提交于 2020-01-23 10:09:28
问题 How can I change the error attributes that are exposed when throwing a ResponseStatusException ? Especially I want to hide the exception , error and status type in the json, but only during production. @RestController public class MyController { @GetMapping("/test") public Object get() { throw new org.springframework.web.server.ResponseStatusException( HttpStatus.Forbidden, "some message"); } } Result: { "timestamp": "2018-11-06T12:16:50.111+0000", "status": 403, "error": "Forbidden",

Adding headers to Spring controllers

人走茶凉 提交于 2020-01-23 08:05:17
问题 I know this question is very similar to this one, but I feel its different and specific enough to warrant its own question here. I've just inherited a Java web app project from a sole developer who left no documentation behind. Its a Spring MVC app with a basic package structure as follows: com.ourOrg.app.controllers ImageController ProgramController UserController com.ourOrg.app.otherPackages Each Controller class is just a POJO annotated with @Controller and @RequestMapping("/blah") . For

Adding headers to Spring controllers

我怕爱的太早我们不能终老 提交于 2020-01-23 08:05:04
问题 I know this question is very similar to this one, but I feel its different and specific enough to warrant its own question here. I've just inherited a Java web app project from a sole developer who left no documentation behind. Its a Spring MVC app with a basic package structure as follows: com.ourOrg.app.controllers ImageController ProgramController UserController com.ourOrg.app.otherPackages Each Controller class is just a POJO annotated with @Controller and @RequestMapping("/blah") . For

Using PropertyOverrideConfigurer with Annotated Classes in Spring 3

痴心易碎 提交于 2020-01-23 07:41:20
问题 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