BAEL-4791: Spring AliasFor Annotation (#10794)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.baeldung.aliasfor;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@RequestMapping
|
||||
public @interface MyMapping {
|
||||
|
||||
@AliasFor(annotation = RequestMapping.class, attribute = "method")
|
||||
RequestMethod[] action() default {};
|
||||
|
||||
@AliasFor(annotation = RequestMapping.class, attribute = "path")
|
||||
String[] value() default {};
|
||||
|
||||
@AliasFor(annotation = RequestMapping.class, attribute = "path")
|
||||
String[] mapping() default {};
|
||||
|
||||
@AliasFor(annotation = RequestMapping.class, attribute = "path")
|
||||
String[] route() default {};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.aliasfor;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@Controller
|
||||
public class MyMappingController {
|
||||
|
||||
@MyMapping(action = RequestMethod.PATCH, route = "/test")
|
||||
public void mappingMethod() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user