Stack Exchange
Spring boot custom annotation does not work
There's a strange problem with springboot annotation.The 3 files I created are as follows.
1.@Interface file1

package com.UserOp.Controller.annotation;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

@Documented
@Retention(RUNTIME)
@Target(METHOD)
public @interface helloX {
    String value() default "Hello Aop.";
}


2.@Aspect file2
package com.UserOp.Controller.annotation;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class helloXAspect {
    @Pointcut("@annotation(com.UserOp.Controller.annotation.helloX)")
    private void cut() { }  
    @Around("cut()")
    public void advice(ProceedingJoinPoint joinPoint){
        System.out.println("Around begin.");
        try {
            joinPoint.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        System.out.println("Around end.");
    }
}


3.test class file3
package com.UserOp.Controller.annotation;
import org.springframework.stereotype.Service;
@Service
public class ABC {
    @helloX
    public void test()
    {
        System.out.println("int hellox test.");
    }
}




4.//spring boot run file4,
package com.UserOp.Controller.useropControllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;
import com.UserOp.Controller.annotation.ABC;
import com.UserOp.Controller.annotation.helloX;
import com.UserOp.DbModel.Users.Cloud_UsersRepository;
import MyJ_CommonLib.MyJ_ReqResult;
import annotation.MyResponseBody;

@Component
public class userController {
    @Autowired
    ABC abc;
    public String UserOp(HttpSession session, HttpServletRequest request, Object object) {
        test();
        return "";
    }
    //@helloX
    void test()
    {
        System.out.println("prepar test!");
        abc.test();
        return;
    }
}




   //The above file is invoked as follows

    package com.UserOp.Controller;
    ....
    @RestController
    public class DoController {
        @Autowired
        userController a_userController;
    ...
        @RequestMapping(value="/Do",method=RequestMethod.GET)
        public String doRoute(@RequestParam String mode,@RequestParam String action
                ,@RequestParam(required=false) String process,HttpSession session,HttpServletRequest request) throws Exception
           {
              a_userController.UserOp(session,request,null);
              return "";
           }
    ...


Please see the  file4,There are two things going on here.

//first,all be right.annotation '@helloX' excute on abc.test();
    void test()
    {
        System.out.println("prepar test!");
        abc.test();
        return;
    }




//but this is error.
            @helloX   //look there,add this notation than nothing happened.
            void test()
            {
                System.out.println("prepar test!");
                //abc.test();
                return;
            }

I don't know why adding @helloX to file3 works fine (abc.test (), but adding @helloX to file4 is not work.and report an error in debug mode:  

        Unable to install breakpoint in com.UserOp.Controller.useropControllers
        .userController$$FastClassBySpringCGLIB$$3389c207 
        due to missing line number attributes. 
        Modify compiler options to generate line number attributes.

        Reason:
        Absent Line Number Information


Probably because file 3 is implementing an interface but file 4 isn't. Both fix your naming to conform to Java standards and use the standard compiler options, which include debug information such as line numbers--as it says to.

I've done both of these, and I'm sure there's no problem. the error message abort breakpoint error,that can be ignore.and i found both 'BUG'.

1.the aop function must  be public,like file4,it should written like this:

@helloX  \r
public   void test()....
and cannot called in this class,it must called by other class.so it to work properly.But I'm confused again.
