Java / Spring Boot Integration
Observe Java and Spring Boot services automatically using the NxtOne Javaagent starter.
The NxtOne Java SDK provides auto-configuration support for Spring Boot projects. It intercepts class loadings, SQL statements, and REST web transactions automatically.
1. Dependency Configuration
Add the NxtOne spring-boot-starter dependency to your project:
Maven (pom.xml)
<dependencies>
<dependency>
<groupId>ai.nxtone</groupId>
<artifactId>nxtone-agent</artifactId>
</dependency>
<dependency>
<groupId>ai.nxtone</groupId>
<artifactId>nxtone-spring</artifactId>
</dependency>
</dependencies>
Gradle (build.gradle.kts)
dependencies {
implementation("io.nxtone:nxtone-spring-boot-starter:0.1.0")
}
2. Application Properties Configuration
Configure NxtOne credentials inside your standard Spring application.properties or application.yml file:
# NxtOne configuration
nxtone.api-key=nxt_live_abc123
nxtone.project-id=billing-service
3. Code Annotation
To define the root boundary, add the @NxtOneAgent annotation to your Spring Boot main application class. This signals the agent to start tracing upon context initialization:
package com.example.billing;
import io.nxtone.annotation.NxtOneAgent;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@NxtOneAgent(sessionName = "billing-portal")
@SpringBootApplication
public class BillingApplication {
public static void main(String[] args) {
SpringApplication.run(BillingApplication.class, args);
}
}
4. Running with the Javaagent
To enable dynamic bytecode instrumentation, you must run the compiled application JAR with the -javaagent argument:
java -javaagent:/path/to/nxtone-agent-0.1.0.jar -jar target/billing-service.jar
Bytecode Safety: If NxtOne fails to instrument a class (e.g. because of Java version differences or missing class files), it gracefully returns the original un-instrumented bytecode so your application continues to run normally.