I am developing a Maven plugin which generates some application metadata related to Spring Controllers. Currently I am unable to get the "Controller" annotation (with its "value" property) of my spring controllers so I am kinda stuck...
How could I get this annotation and its value ?. Thankx
This code let me get the desired values. Thankx to all
Related
I am using the Ardalis Clean Architecture for one of my projects. I am getting the above-mentioned error if I have the same action method (for example: Edit) in more than one controller and I try to call that method from anywhere. But if I add the following line in the controller just above where you declare public class and the controller name then the error disappear.
[Route("[controller]/[action]")]
I don't face the same issue in a normal asp.net core 6.0 project so I guess there is something in the Ardalis Clean Architecture template that is causing this.
I have Spring MVC project (gradle, kotlin) and Idea inspection shows me my MVC controller methods as unused.
How can I make the inspection tool recognize that those methods are entry points and should not be analyzed for usages?
You can mark the spring mvc annotations such as #PostMapping, #GetMapping etc as entrypoint annotations in the idea inspection profile
I need to store "hostName" parameter in my Spring MVC application configuration (for writing links in templates to static recourses, which are on static.hostName). I assume hardcoding this is bad, so where should I store it?
Web.xml, or servlet-context.xml? And how do I get it?
Thanks.
With a PropertyPlaceholderConfigurer you can externalize beans (and primitives) into a properties file. You can inject those beans with SpEl and #Value:
#Value("${hostname}")
private String hostname;
You can find a configuration example in the reference documentation.
Actually I want to store all the routing in the database. I wrote custom annotation class called VendorRoute I can read this annotation for a single controller, but does anybody know how to read this annotation for all controllers in application?
So I solved my problem. In Sf2 it's impossible out of the box. Check out my implementation https://github.com/Codeforges/CayenneCoreBundle/blob/master/Annotations/Driver/CayenneRouteDriver.php#L83
I'm using Spring Roo to build my service layer, the layer needs json interface without jspx files. But I tried controller Scaffold or controller all all of them generate view layer. So my question, how can I generate controller layer without view to build a service project?
Thanks.
If you want to just create a Controller Class without any views, use following command
controller class --class ~.domain.NameOfController
If you just want a web service layer you can run something similar to:
service --interface ~.service.SomeEntityService --entity ~.domain.SomeEntity