Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is kind of strange that you are using your unit test also as a <code>@Configuration</code> source.</p> <p>You should remove the <code>@Configuration</code> annotation from the unit test and move the <code>testAOP()</code> bean definition to <code>WebConfig</code>. But most importantly the bean being advised <strong>must not be created manually, but by Spring</strong>:</p> <pre><code>@ContextConfiguration(classes={WebConfig.class}) @WebAppConfiguration("src/main/java") public class AopConfigTest extends AbstractJUnit4SpringContextTests { @Autowired private TestAOP testAop; @Autowired private TestAOPClient client; @Test public void assertTestConfigIsActive() { client.relayMessage("hello"); assertThat(((TestAOP)applicationContext.getBean("testAop")).getMessage(), equalTo("hello")); } } </code></pre> <p>Updated config with the bean definition:</p> <pre><code>@Configuration @EnableWebMvc @EnableAspectJAutoProxy(proxyTargetClass=false) @ComponentScan(value={"my.package.path.config", "my.package.path.web"}) public class WebConfig { @Bean public TestAOP testAop() throws Exception { return new TestAOP(); } @Bean public TestAOPClient testAopClient() throws Exception { return new TestAOPClient(); } } </code></pre> <p>If your target was to test whether the AOP configuration works and <code>TestAOP</code> is really a testing bean (not just a dummy name for this question), you can create a special <code>TestConfig</code> configuration class, move the bean definition there and use it from the test <code>@ContextConfiguration(classes={WebConfig.class,TestConfig.class})</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload