I have myannotation and whenever my method(which has myannotation) is executed then AOP should be called but which is not working in my spring boot controller.But which is working for methods which has other annotations.Please help me to understand about what happens.
@Controller
@RequestMapping("user")
public class ArticleController {
@GetMapping("article/{id}")
@MyAnnotation // here it is
public ResponseEntity getArticleById(@PathVariable("id") Integer id)
{
return new ResponseEntity(dummyMethod(), HttpStatus.OK);
}
public String dummyMethod() {
System.out.println("Dummy method with MyAnnotation");
return "HelloWorld!";
}
}
@Controller
@RequestMapping("user")
public class ArticleController {
@GetMapping("article/{id}")
public ResponseEntity getArticleById(@PathVariable("id") Integer id)
{
return new ResponseEntity(dummyMethod(), HttpStatus.OK);
}
@MyAnnotation //here it is
public String dummyMethod() {
System.out.println("Dummy method with MyAnnotation");
return "HelloWorld!";
}
}
@Service
public class ArticleService {
@MyAnnotation //here it is
public String dummyMethod() {
System.out.println("Dummy method with MyAnnotation");
return "HelloWorld!";
}
}
I have myannotation and whenever my method(which has myannotation) is executed then AOP should be called but which is not working in my spring boot controller.But which is working for methods which has other annotations.Please help me to understand about what happens.
[code]@Controller @RequestMapping("user") public class ArticleController {
@GetMapping("article/{id}") @MyAnnotation // here it is public ResponseEntity getArticleById(@PathVariable("id") Integer id) { return new ResponseEntity(dummyMethod(), HttpStatus.OK); }
public String dummyMethod() { System.out.println("Dummy method with MyAnnotation"); return "HelloWorld!"; } } [/code]
[code]@Controller @RequestMapping("user") public class ArticleController {
@GetMapping("article/{id}") public ResponseEntity getArticleById(@PathVariable("id") Integer id) { return new ResponseEntity(dummyMethod(), HttpStatus.OK); } @MyAnnotation //here it is public String dummyMethod() { System.out.println("Dummy method with MyAnnotation"); return "HelloWorld!"; } } [/code]
Log:(Not Working)
[code]Dummy method with MyAnnotation [/code]
[b]Scenario 3: (Not Working)[/b]
[code]@Service public class ArticleService { @MyAnnotation //here it is public String dummyMethod() { System.out.println("Dummy method with MyAnnotation"); return "HelloWorld!"; } } [/code]