diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml
index 1b0eead1286..60c5e42855d 100644
--- a/spring-boot-autoconfigure/pom.xml
+++ b/spring-boot-autoconfigure/pom.xml
@@ -151,6 +151,12 @@
geronimo-jms_1.1_spec
true
+
+ org.aspectj
+ aspectjweaver
+ 1.7.3
+ true
+
${project.groupId}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java
index 6e37281153d..9971cd8bbde 100644
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java
@@ -37,13 +37,13 @@ public class AopAutoConfiguration {
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = false)
- @ConditionalOnExpression("!${spring.aop.proxyTargetClass:false}")
+ @ConditionalOnExpression("!${spring.aop.proxyTargetClass:true}")
public static class JdkDynamicAutoProxyConfiguration {
}
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true)
- @ConditionalOnExpression("${spring.aop.proxyTargetClass:false}")
+ @ConditionalOnExpression("${spring.aop.proxyTargetClass:true}")
public static class CglibAutoProxyConfiguration {
}
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/AopAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/AopAutoConfigurationTests.java
new file mode 100644
index 00000000000..31cc7c2db00
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/AopAutoConfigurationTests.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2012-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.boot.autoconfigure.aop;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.junit.Test;
+import org.springframework.boot.TestUtils;
+import org.springframework.boot.autoconfigure.aop.AopAutoConfigurationTests.TestInterface;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Tests for {@link AopAutoConfiguration}.
+ *
+ * @author Eberhard Wolff
+ */
+public class AopAutoConfigurationTests {
+
+ public interface TestInterface {
+
+ public abstract void foo();
+
+ }
+
+ private AnnotationConfigApplicationContext context;
+
+ @Test
+ public void testAopAutoConfigurationProxyTargetClass() {
+ this.context = new AnnotationConfigApplicationContext();
+ this.context.register(TestConfiguration.class, AopAutoConfiguration.class);
+ TestUtils.addEnviroment(this.context, "spring.aop.proxyTargetClass:true");
+ TestUtils.addEnviroment(this.context, "spring.aop.auto:true");
+ this.context.refresh();
+ TestAspect aspect = this.context.getBean(TestAspect.class);
+ assertFalse(aspect.isCalled());
+ TestBean bean = this.context.getBean(TestBean.class);
+ bean.foo();
+ assertTrue(aspect.isCalled());
+ }
+
+
+ @Test
+ public void testAopAutoConfigurationNoProxyTargetClass() {
+ this.context = new AnnotationConfigApplicationContext();
+ this.context.register(TestConfiguration.class, AopAutoConfiguration.class);
+ TestUtils.addEnviroment(this.context, "spring.aop.proxyTargetClass:false");
+ TestUtils.addEnviroment(this.context, "spring.aop.auto:true");
+ this.context.refresh();
+ TestAspect aspect = this.context.getBean(TestAspect.class);
+ assertFalse(aspect.isCalled());
+ TestInterface bean = this.context.getBean(TestInterface.class);
+ bean.foo();
+ assertTrue(aspect.isCalled());
+ }
+
+ @Configuration
+ protected static class TestConfiguration {
+ @Bean
+ public TestAspect aspect() {
+ return new TestAspect();
+ }
+ @Bean
+ public TestInterface bean() {
+ return new TestBean();
+ }
+ }
+
+ protected static class TestBean implements TestInterface {
+ @Override
+ public void foo() {
+ }
+ }
+
+ @Aspect
+ protected static class TestAspect {
+ private boolean called;
+
+ public boolean isCalled() {
+ return called;
+ }
+
+ @Before("execution(* foo(..))")
+ public void before() {
+ called=true;
+ }
+ }
+
+}