@Before Advice Annotation not Applied in the Spring Application












0















I have been trying to develop a small application that demonstrates the @Before Annotation , but its not working



pom.xml



<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>aopdemo</groupId>
<artifactId>aopdemo</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.11</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.0</version>
</dependency>
</dependencies>




AccoutDAO.java file is



   package org.java.aop.dao;

import org.springframework.stereotype.Component;
@Component
public class AccoutDAO {
public void addAccount()
{
System.out.println("Adding account"+getClass());
}
}


The Aspect configuration file is



   package org.java.aop.aspects;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class MyAspects {

@Before("execution(public void addAccount())")
public void display()
{
System.out.println("=====================>>CALLING Aspects");
}
}


The spring config file(spring-config.xml) is



    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<bean id="accountDAO" class="org.java.aop.dao.AccoutDAO">
</bean>
<aop:aspectj-autoproxy/>

</beans>


And finally my main code is



    package org.java.aop;
import org.java.aop.dao.AccoutDAO;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainDemo {

public static void main(String arg)
{
try
{
ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
AccoutDAO accoutDAO=context.getBean("accountDAO",AccoutDAO.class);
accoutDAO.addAccount();
context.close();
}
catch (Exception e)
{
System.out.print(e);
}
}
}


I am able to get the output as "INFO: Loading XML bean definitions from class path resource [spring-config.xml]
Adding accountclass org.java.aop.dao.AccoutDAO
Nov 22, 2018 2:06:14 AM org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing org.springframework.context.support.ClassPathXmlApplicationContext@1ed6993a: startup date [Thu Nov 22 02:06:14 IST 2018]; root of context hierarchy"



But i could not able to get the output for @Before Annotation.Kindly tell me whats wrong in this code










share|improve this question



























    0















    I have been trying to develop a small application that demonstrates the @Before Annotation , but its not working



    pom.xml



    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>aopdemo</groupId>
    <artifactId>aopdemo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>5.0.6.RELEASE</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>5.0.6.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>5.0.6.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.0.6.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aspects</artifactId>
    <version>5.0.6.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.6.11</version>
    </dependency>
    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.9.0</version>
    </dependency>
    </dependencies>




    AccoutDAO.java file is



       package org.java.aop.dao;

    import org.springframework.stereotype.Component;
    @Component
    public class AccoutDAO {
    public void addAccount()
    {
    System.out.println("Adding account"+getClass());
    }
    }


    The Aspect configuration file is



       package org.java.aop.aspects;

    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Before;
    import org.springframework.stereotype.Component;

    @Aspect
    @Component
    public class MyAspects {

    @Before("execution(public void addAccount())")
    public void display()
    {
    System.out.println("=====================>>CALLING Aspects");
    }
    }


    The spring config file(spring-config.xml) is



        <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
    <bean id="accountDAO" class="org.java.aop.dao.AccoutDAO">
    </bean>
    <aop:aspectj-autoproxy/>

    </beans>


    And finally my main code is



        package org.java.aop;
    import org.java.aop.dao.AccoutDAO;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    public class MainDemo {

    public static void main(String arg)
    {
    try
    {
    ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
    AccoutDAO accoutDAO=context.getBean("accountDAO",AccoutDAO.class);
    accoutDAO.addAccount();
    context.close();
    }
    catch (Exception e)
    {
    System.out.print(e);
    }
    }
    }


    I am able to get the output as "INFO: Loading XML bean definitions from class path resource [spring-config.xml]
    Adding accountclass org.java.aop.dao.AccoutDAO
    Nov 22, 2018 2:06:14 AM org.springframework.context.support.AbstractApplicationContext doClose
    INFO: Closing org.springframework.context.support.ClassPathXmlApplicationContext@1ed6993a: startup date [Thu Nov 22 02:06:14 IST 2018]; root of context hierarchy"



    But i could not able to get the output for @Before Annotation.Kindly tell me whats wrong in this code










    share|improve this question

























      0












      0








      0








      I have been trying to develop a small application that demonstrates the @Before Annotation , but its not working



      pom.xml



      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <groupId>aopdemo</groupId>
      <artifactId>aopdemo</artifactId>
      <version>1.0-SNAPSHOT</version>
      <dependencies>
      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>5.0.6.RELEASE</version>
      </dependency>

      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
      <version>5.0.6.RELEASE</version>
      </dependency>
      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>5.0.6.RELEASE</version>
      </dependency>
      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>5.0.6.RELEASE</version>
      </dependency>
      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aspects</artifactId>
      <version>5.0.6.RELEASE</version>
      </dependency>
      <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>1.6.11</version>
      </dependency>
      <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>1.9.0</version>
      </dependency>
      </dependencies>




      AccoutDAO.java file is



         package org.java.aop.dao;

      import org.springframework.stereotype.Component;
      @Component
      public class AccoutDAO {
      public void addAccount()
      {
      System.out.println("Adding account"+getClass());
      }
      }


      The Aspect configuration file is



         package org.java.aop.aspects;

      import org.aspectj.lang.annotation.Aspect;
      import org.aspectj.lang.annotation.Before;
      import org.springframework.stereotype.Component;

      @Aspect
      @Component
      public class MyAspects {

      @Before("execution(public void addAccount())")
      public void display()
      {
      System.out.println("=====================>>CALLING Aspects");
      }
      }


      The spring config file(spring-config.xml) is



          <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/context"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
      <bean id="accountDAO" class="org.java.aop.dao.AccoutDAO">
      </bean>
      <aop:aspectj-autoproxy/>

      </beans>


      And finally my main code is



          package org.java.aop;
      import org.java.aop.dao.AccoutDAO;
      import org.springframework.context.support.ClassPathXmlApplicationContext;
      public class MainDemo {

      public static void main(String arg)
      {
      try
      {
      ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
      AccoutDAO accoutDAO=context.getBean("accountDAO",AccoutDAO.class);
      accoutDAO.addAccount();
      context.close();
      }
      catch (Exception e)
      {
      System.out.print(e);
      }
      }
      }


      I am able to get the output as "INFO: Loading XML bean definitions from class path resource [spring-config.xml]
      Adding accountclass org.java.aop.dao.AccoutDAO
      Nov 22, 2018 2:06:14 AM org.springframework.context.support.AbstractApplicationContext doClose
      INFO: Closing org.springframework.context.support.ClassPathXmlApplicationContext@1ed6993a: startup date [Thu Nov 22 02:06:14 IST 2018]; root of context hierarchy"



      But i could not able to get the output for @Before Annotation.Kindly tell me whats wrong in this code










      share|improve this question














      I have been trying to develop a small application that demonstrates the @Before Annotation , but its not working



      pom.xml



      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <groupId>aopdemo</groupId>
      <artifactId>aopdemo</artifactId>
      <version>1.0-SNAPSHOT</version>
      <dependencies>
      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>5.0.6.RELEASE</version>
      </dependency>

      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
      <version>5.0.6.RELEASE</version>
      </dependency>
      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>5.0.6.RELEASE</version>
      </dependency>
      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>5.0.6.RELEASE</version>
      </dependency>
      <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aspects</artifactId>
      <version>5.0.6.RELEASE</version>
      </dependency>
      <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>1.6.11</version>
      </dependency>
      <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>1.9.0</version>
      </dependency>
      </dependencies>




      AccoutDAO.java file is



         package org.java.aop.dao;

      import org.springframework.stereotype.Component;
      @Component
      public class AccoutDAO {
      public void addAccount()
      {
      System.out.println("Adding account"+getClass());
      }
      }


      The Aspect configuration file is



         package org.java.aop.aspects;

      import org.aspectj.lang.annotation.Aspect;
      import org.aspectj.lang.annotation.Before;
      import org.springframework.stereotype.Component;

      @Aspect
      @Component
      public class MyAspects {

      @Before("execution(public void addAccount())")
      public void display()
      {
      System.out.println("=====================>>CALLING Aspects");
      }
      }


      The spring config file(spring-config.xml) is



          <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/context"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
      <bean id="accountDAO" class="org.java.aop.dao.AccoutDAO">
      </bean>
      <aop:aspectj-autoproxy/>

      </beans>


      And finally my main code is



          package org.java.aop;
      import org.java.aop.dao.AccoutDAO;
      import org.springframework.context.support.ClassPathXmlApplicationContext;
      public class MainDemo {

      public static void main(String arg)
      {
      try
      {
      ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
      AccoutDAO accoutDAO=context.getBean("accountDAO",AccoutDAO.class);
      accoutDAO.addAccount();
      context.close();
      }
      catch (Exception e)
      {
      System.out.print(e);
      }
      }
      }


      I am able to get the output as "INFO: Loading XML bean definitions from class path resource [spring-config.xml]
      Adding accountclass org.java.aop.dao.AccoutDAO
      Nov 22, 2018 2:06:14 AM org.springframework.context.support.AbstractApplicationContext doClose
      INFO: Closing org.springframework.context.support.ClassPathXmlApplicationContext@1ed6993a: startup date [Thu Nov 22 02:06:14 IST 2018]; root of context hierarchy"



      But i could not able to get the output for @Before Annotation.Kindly tell me whats wrong in this code







      spring spring-aop






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 20:43









      Arul SujuArul Suju

      96110




      96110
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The above problem is resolved by adding component scan in spring-config.xml



           <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/context"
          xmlns:aop="http://www.springframework.org/schema/aop"
          xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
          <bean id="accountDAO" class="org.java.aop.dao.AccoutDAO">
          </bean>
          <aop:aspectj-autoproxy/>
          <context:component-scan base-package="org.java.aop"/>
          </beans>





          share|improve this answer
























          • Still you should fix your dependency management. You have a very old version of aspectjrt versus a relatively new one of aspectjweaver. Furthermore, aspectjweaver is a superset of aspectjrt, so you do not need the runtime at all. And according to the Maven dependencies of spring-aop even aspectjweaver is an optional dependency. Try if it works without both, but definitely you should get rid of aspectjrt including the version mismatch.

            – kriegaex
            Dec 11 '18 at 5:16











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420190%2fbefore-advice-annotation-not-applied-in-the-spring-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The above problem is resolved by adding component scan in spring-config.xml



           <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/context"
          xmlns:aop="http://www.springframework.org/schema/aop"
          xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
          <bean id="accountDAO" class="org.java.aop.dao.AccoutDAO">
          </bean>
          <aop:aspectj-autoproxy/>
          <context:component-scan base-package="org.java.aop"/>
          </beans>





          share|improve this answer
























          • Still you should fix your dependency management. You have a very old version of aspectjrt versus a relatively new one of aspectjweaver. Furthermore, aspectjweaver is a superset of aspectjrt, so you do not need the runtime at all. And according to the Maven dependencies of spring-aop even aspectjweaver is an optional dependency. Try if it works without both, but definitely you should get rid of aspectjrt including the version mismatch.

            – kriegaex
            Dec 11 '18 at 5:16
















          0














          The above problem is resolved by adding component scan in spring-config.xml



           <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/context"
          xmlns:aop="http://www.springframework.org/schema/aop"
          xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
          <bean id="accountDAO" class="org.java.aop.dao.AccoutDAO">
          </bean>
          <aop:aspectj-autoproxy/>
          <context:component-scan base-package="org.java.aop"/>
          </beans>





          share|improve this answer
























          • Still you should fix your dependency management. You have a very old version of aspectjrt versus a relatively new one of aspectjweaver. Furthermore, aspectjweaver is a superset of aspectjrt, so you do not need the runtime at all. And according to the Maven dependencies of spring-aop even aspectjweaver is an optional dependency. Try if it works without both, but definitely you should get rid of aspectjrt including the version mismatch.

            – kriegaex
            Dec 11 '18 at 5:16














          0












          0








          0







          The above problem is resolved by adding component scan in spring-config.xml



           <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/context"
          xmlns:aop="http://www.springframework.org/schema/aop"
          xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
          <bean id="accountDAO" class="org.java.aop.dao.AccoutDAO">
          </bean>
          <aop:aspectj-autoproxy/>
          <context:component-scan base-package="org.java.aop"/>
          </beans>





          share|improve this answer













          The above problem is resolved by adding component scan in spring-config.xml



           <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/context"
          xmlns:aop="http://www.springframework.org/schema/aop"
          xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
          <bean id="accountDAO" class="org.java.aop.dao.AccoutDAO">
          </bean>
          <aop:aspectj-autoproxy/>
          <context:component-scan base-package="org.java.aop"/>
          </beans>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 6:18









          Arul SujuArul Suju

          96110




          96110













          • Still you should fix your dependency management. You have a very old version of aspectjrt versus a relatively new one of aspectjweaver. Furthermore, aspectjweaver is a superset of aspectjrt, so you do not need the runtime at all. And according to the Maven dependencies of spring-aop even aspectjweaver is an optional dependency. Try if it works without both, but definitely you should get rid of aspectjrt including the version mismatch.

            – kriegaex
            Dec 11 '18 at 5:16



















          • Still you should fix your dependency management. You have a very old version of aspectjrt versus a relatively new one of aspectjweaver. Furthermore, aspectjweaver is a superset of aspectjrt, so you do not need the runtime at all. And according to the Maven dependencies of spring-aop even aspectjweaver is an optional dependency. Try if it works without both, but definitely you should get rid of aspectjrt including the version mismatch.

            – kriegaex
            Dec 11 '18 at 5:16

















          Still you should fix your dependency management. You have a very old version of aspectjrt versus a relatively new one of aspectjweaver. Furthermore, aspectjweaver is a superset of aspectjrt, so you do not need the runtime at all. And according to the Maven dependencies of spring-aop even aspectjweaver is an optional dependency. Try if it works without both, but definitely you should get rid of aspectjrt including the version mismatch.

          – kriegaex
          Dec 11 '18 at 5:16





          Still you should fix your dependency management. You have a very old version of aspectjrt versus a relatively new one of aspectjweaver. Furthermore, aspectjweaver is a superset of aspectjrt, so you do not need the runtime at all. And according to the Maven dependencies of spring-aop even aspectjweaver is an optional dependency. Try if it works without both, but definitely you should get rid of aspectjrt including the version mismatch.

          – kriegaex
          Dec 11 '18 at 5:16




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420190%2fbefore-advice-annotation-not-applied-in-the-spring-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          WPF add header to Image with URL pettitions [duplicate]