Getting Dependencies without Spring Boot
We recommend a Spring Boot first approach when using Apache Pulsar support for Spring. However, if you do not use Spring Boot, the preferred way to get the dependencies is to use the provided BOM to ensure a consistent version of modules is used throughout your entire project. The following example shows how to do so for both Maven and Gradle:
-
Maven
-
Gradle
<dependencyManagement>
<dependencies>
<!-- ... other dependency elements ... -->
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-spring-bom</artifactId>
<version>3.0.0-M1-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
plugins {
id "io.spring.dependency-management" version "1.1.7"
}
dependencyManagement {
imports {
mavenBom 'org.apache.pulsar:pulsar-spring-bom:3.0.0-M1-SNAPSHOT'
}
}
A minimal set of dependencies for Apache Pulsar support for Spring typically looks like the following:
-
Maven
-
Gradle
<dependencies>
<!-- ... other dependency elements ... -->
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-spring</artifactId>
</dependency>
</dependencies>
dependencies {
implementation "org.apache.pulsar:pulsar-spring"
}
If you use additional features you need to also include the appropriate dependencies.
Apache Pulsar support for Spring builds against Spring Framework 7.0.10 but should generally work with any newer version of Spring Framework 7.x.
Many users are likely to run afoul of the fact that Apache Pulsar support for Spring’s transitive dependencies resolve Spring Framework 7.0.10, which can cause strange classpath problems.
The easiest way to resolve this is to use the spring-framework-bom within your dependencyManagement section as follows:
-
Maven
-
Gradle
<dependencyManagement>
<dependencies>
<!-- ... other dependency elements ... -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>7.0.10</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
plugins {
id "io.spring.dependency-management" version "1.1.7"
}
dependencyManagement {
imports {
mavenBom 'org.springframework:spring-framework-bom:7.0.10'
}
}
The preceding example ensures that all the transitive dependencies of Apache Pulsar support for Spring use the Spring 7.0.10 modules.