Skip to content

Commit e7e150c

Browse files
authored
NoSuchBeanDefinitionException in spring-bean's old version (#807)
1 parent fa4a43f commit e7e150c

3 files changed

Lines changed: 51 additions & 16 deletions

File tree

sentry-spring-boot-starter/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@
4343
<artifactId>spring-boot-starter-test</artifactId>
4444
<scope>test</scope>
4545
</dependency>
46+
4647
</dependencies>
4748

4849
<dependencyManagement>
4950
<dependencies>
5051
<dependency>
5152
<groupId>org.springframework.boot</groupId>
5253
<artifactId>spring-boot-dependencies</artifactId>
53-
<version>1.5.17.RELEASE</version>
54+
<version>1.5.1.RELEASE</version>
5455
<type>pom</type>
5556
<scope>import</scope>
5657
</dependency>

sentry-spring-boot-starter/src/main/java/io/sentry/spring/autoconfigure/SentryAutoConfiguration.java

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
import io.sentry.event.helper.ShouldSendEventCallback;
1111
import io.sentry.spring.SentryExceptionResolver;
1212
import io.sentry.spring.SentryServletContextInitializer;
13-
import org.springframework.beans.factory.annotation.Autowired;
14-
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
15-
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
16-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
17-
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
13+
import org.springframework.boot.autoconfigure.condition.*;
1814
import org.springframework.boot.context.properties.EnableConfigurationProperties;
1915
import org.springframework.boot.web.servlet.ServletContextInitializer;
2016
import org.springframework.context.annotation.Bean;
@@ -58,6 +54,39 @@ public ServletContextInitializer sentryServletContextInitializer() {
5854
return new SentryServletContextInitializer();
5955
}
6056

57+
/**
58+
* Initializes a {@link List<EventBuilderHelper>}.
59+
*
60+
* @return a new instance of {@link List<EventBuilderHelper>}.
61+
*/
62+
@Bean
63+
@ConditionalOnMissingBean(EventBuilderHelper.class)
64+
public List<EventBuilderHelper> defaultEventBuilderHelpers() {
65+
return Collections.emptyList();
66+
}
67+
68+
/**
69+
* Initializes a {@link List<EventSendCallback>}.
70+
*
71+
* @return a new instance of {@link List<EventSendCallback>}.
72+
*/
73+
@Bean
74+
@ConditionalOnMissingBean(EventSendCallback.class)
75+
public List<EventSendCallback> defaultEventSendCallbacks() {
76+
return Collections.emptyList();
77+
}
78+
79+
/**
80+
* Initializes a {@link List<ShouldSendEventCallback>}.
81+
*
82+
* @return a new instance of {@link List<ShouldSendEventCallback>}.
83+
*/
84+
@Bean
85+
@ConditionalOnMissingBean(ShouldSendEventCallback.class)
86+
public List<ShouldSendEventCallback> defaultShouldSendEventCallbacks() {
87+
return Collections.emptyList();
88+
}
89+
6190
/**
6291
* Initializes a {@link SentryClient}.
6392
*
@@ -67,9 +96,9 @@ public ServletContextInitializer sentryServletContextInitializer() {
6796
@ConditionalOnMissingBean(SentryClient.class)
6897
@ConditionalOnProperty(name = "sentry.init-default-client", havingValue = "true", matchIfMissing = true)
6998
public SentryClient sentryClient(SentryProperties properties,
70-
@Autowired(required = false) List<EventBuilderHelper> eventBuilderHelpers,
71-
@Autowired(required = false) List<EventSendCallback> eventSendCallbacks,
72-
@Autowired(required = false) List<ShouldSendEventCallback> shouldSendEventCallbacks) {
99+
List<EventBuilderHelper> eventBuilderHelpers,
100+
List<EventSendCallback> eventSendCallbacks,
101+
List<ShouldSendEventCallback> shouldSendEventCallbacks) {
73102
String dsn = properties.getDsn() != null ? properties.getDsn().toString() : null;
74103

75104
SentryOptions sentryOptions = SentryOptions.from(createLookup(properties), dsn, null);

sentry-spring/pom.xml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
<name>Sentry-Java for Spring</name>
1515
<description>Spring exception handler and servlet initializer for sending exceptions to Sentry.</description>
1616

17-
<properties>
18-
<spring.version>4.3.10.RELEASE</spring.version>
19-
<spring-boot.version>1.5.4.RELEASE</spring-boot.version>
20-
</properties>
21-
2217
<dependencies>
2318
<dependency>
2419
<groupId>${project.groupId}</groupId>
@@ -27,13 +22,11 @@
2722
<dependency>
2823
<groupId>org.springframework</groupId>
2924
<artifactId>spring-webmvc</artifactId>
30-
<version>${spring.version}</version>
3125
<scope>provided</scope>
3226
</dependency>
3327
<dependency>
3428
<groupId>org.springframework.boot</groupId>
3529
<artifactId>spring-boot</artifactId>
36-
<version>${spring-boot.version}</version>
3730
<scope>provided</scope>
3831
</dependency>
3932
<dependency>
@@ -85,6 +78,18 @@
8578
</dependency>
8679
</dependencies>
8780

81+
<dependencyManagement>
82+
<dependencies>
83+
<dependency>
84+
<groupId>org.springframework.boot</groupId>
85+
<artifactId>spring-boot-dependencies</artifactId>
86+
<version>1.5.1.RELEASE</version>
87+
<type>pom</type>
88+
<scope>import</scope>
89+
</dependency>
90+
</dependencies>
91+
</dependencyManagement>
92+
8893
<build>
8994
<plugins>
9095
<plugin>

0 commit comments

Comments
 (0)