Getting Dependencies without Spring Boot

We recommend a Spring Boot first approach when using Spring for Apache Pulsar. 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

pom.xml
<dependencyManagement>
	<dependencies>
		<!-- ... other dependency elements ... -->
		<dependency>
			<groupId>org.springframework.pulsar</groupId>
			<artifactId>spring-pulsar-bom</artifactId>
			<version>1.0.3</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>
build.gradle
plugins {
	id "io.spring.dependency-management" version "1.1.4"
}

dependencyManagement {
	imports {
		mavenBom 'org.springframework.pulsar:spring-pulsar-bom:1.0.3'
	}
}

A minimal Spring for Apache Pulsar set of dependencies typically looks like the following:

  • Maven

  • Gradle

pom.xml
<dependencies>
	<!-- ... other dependency elements ... -->
	<dependency>
		<groupId>org.springframework.pulsar</groupId>
		<artifactId>spring-pulsar</artifactId>
	</dependency>
</dependencies>
build.gradle
dependencies {
	implementation "org.springframework.pulsar:spring-pulsar"
}

If you use additional features (such as Reactive), you need to also include the appropriate dependencies.

Spring for Apache Pulsar builds against Spring Framework 6.1.4 but should generally work with any newer version of Spring Framework 6.x. Many users are likely to run afoul of the fact that Spring for Apache Pulsar’s transitive dependencies resolve Spring Framework 6.1.4, 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

pom.xml
<dependencyManagement>
	<dependencies>
		<!-- ... other dependency elements ... -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-framework-bom</artifactId>
			<version>6.1.4</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>
build.gradle
plugins {
	id "io.spring.dependency-management" version "1.1.4"
}

dependencyManagement {
	imports {
		mavenBom 'org.springframework:spring-framework-bom:6.1.4'
	}
}

The preceding example ensures that all the transitive dependencies of Spring for Apache Pulsar use the Spring 6.1.4 modules.