Getting Started with Spring Content Metadata Extraction
What you'll build
We'll build on the previous guide Getting Started with Spring Content REST API.
What you'll need
-
About 30 minutes
-
A favorite text editor or IDE
-
JDK 1.8 or later
-
Maven 3.0+
How to complete this guide
Before we begin let's set up our development environment:
-
Download and unzip the source repository for this guide, or clone it using Git:
git clone https://github.com/intesys/spring-content-gettingstarted.git -
We are going to start where Getting Started with Spring Content REST API leaves off so
cdintospring-content-gettingstarted/spring-content-rest/complete
When you’re finished, you can check your results against the code in
spring-content-gettingstarted/spring-content-with-metadata-extraction/complete.
Update dependencies
Add the it.intesys:spring-content-metadata-extraction-boot-starter dependency.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-content-with-metadata-extraction</artifactId>
<parent>
<groupId>it.intesys</groupId>
<artifactId>gettingstarted-spring-content</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>it.intesys</groupId>
<artifactId>spring-content-commons</artifactId>
<version>${spring.content.version}</version>
</dependency>
<dependency>
<groupId>it.intesys</groupId>
<artifactId>spring-content-fs-boot-starter</artifactId>
<version>${spring.content.version}</version>
</dependency>
<dependency>
<groupId>it.intesys</groupId>
<artifactId>spring-content-rest-boot-starter</artifactId>
<version>${spring.content.version}</version>
</dependency>
<dependency>
<groupId>it.intesys</groupId>
<artifactId>spring-content-metadata-extraction-boot-starter</artifactId>
<version>${spring.content.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.paulcwarren</groupId>
<artifactId>ginkgo4j</artifactId>
<version>${ginkgo.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Update FileContentStore
The Metadata Extraction module doesn't require any changes to your ContentStore interface.
To be able to extract metadata from files, you need to import the MetadataExtractionService in your class:
@Service
public class MyServiceImpl implements MyService {
private MetadataExtractionService metadataExtractionService;
public MyServiceImpl(MetadataExtractionService metadataExtractionService) {
this.metadataExtractionService = metadataExtractionService; (1)
}
public Map<String, Object> getFileMetadata(File file) {
return metadataExtractionService.extractMetadata(file); (2)
}
}
Build an executable JAR
If you are using Maven, you can run the application using mvn spring-boot:run.
Or you can build the JAR file with mvn clean package and run the JAR
by typing:
java -jar target/gettingstarted-spring-content-with-metadata-extraction-0.0.1.jar
Test Metadata Extraction
Create an entity from a real file:
curl -X POST --form 'file=@Test.pdf' http://localhost:8080/files/from-real-file
And you should see a response like this, with the metadata fields populated:
File successfully saved. Metadata: {fileName=Test.pdf, lastModifiedTime=2026-04-28T13:26:45.8672278Z, lastAccessTime=2026-04-28T13:26:45.8707391Z, size=39616, creationTime=2026-04-28T13:26:45.866221Z, fileExtension=pdf, mimeType=application/pdf}
Summary
Congratulations! You've just written a simple application that uses Spring Content and Spring Content Metadata Extraction to automatically extract metadata from your content.
This guide demonstrates the Spring Content Metadata Extraction Module. For more details see the Spring Content Metadata Extraction reference guide.