SC

Java library · Spring Boot

TM1 Spring Boot starter

The TM1 client in your Spring Boot application

Add the starter, set a few tm1.* properties, and inject a ready Tm1Client. Session pooling, per-user impersonation and metrics come with it, and the companion module wires a TM1 container into your Spring Boot tests.

API docs Source on GitHub

Pre-release. TM1 Spring Boot starter isn’t on Maven Central yet. The API docs track the latest code on master, and the version shown in them is a snapshot. To try it before the first release, build it from source.

  1. Have a TM1 server to talk to. To run one on your own computer, follow Run Planning Analytics on your own computer. You need your own licensed copy of TM1 Server.

  2. Add the starter to a Spring Boot 4 application.

    Gradle (Kotlin)
    implementation("io.skipcheck:tm1-spring-boot-starter:<version>")
  3. Tell it where TM1 is. The starter connects with the tm1 settings in application.yml; these are the defaults of a server set up with the link above:

    application.yml
    # src/main/resources/application.yml
    tm1:
      # Where TM1 is: the server's address, as for tm1-server on this computer
      address: http://localhost:8010
      # Who to log in as: tm1-server's default admin, with no password
      user: admin
      password: ""
      # With Cognos (CAM) security, also name the CAM namespace:
      # namespace: LDAP

    For a server elsewhere, change the address. Keep a real password out of the file, for example with password: ${TM1_PASSWORD} and an environment variable.

  4. Say hello. The starter builds a Tm1Client from those settings; ask for it, and use it. This prints the server’s version and lists its cubes when the application starts:

    Java
    import org.springframework.boot.ApplicationRunner;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.annotation.Bean;
    
    import io.skipcheck.tm1.client.Tm1Client;
    import io.skipcheck.tm1.client.model.Cube;
    import io.skipcheck.tm1.client.odata.ODataQuery;
    
    @SpringBootApplication
    public class HelloTm1Application {
    
        public static void main(String[] args) {
            SpringApplication.run(HelloTm1Application.class, args);
        }
    
        // The starter built the client from the tm1 settings: just ask for it
        @Bean
        ApplicationRunner hello(Tm1Client tm1) {
            return args -> tm1.session()
                .version()
                .doOnNext(version -> System.out.println("Hello from TM1 " + version))
                .thenMany(tm1.cubes().modelCubes(ODataQuery.none().select(Cube.NAME)))
                .doOnNext(cube -> System.out.println("  " + cube.name()))
                .then()
                .block(); // fine at startup; in a web request, return the Flux instead
        }
    
    }

    Run it with ./gradlew bootRun (or mvn spring-boot:run):

    Output
    Hello from TM1 11.8.03500.6
      Plan_BudgetPlan
      SalesCube
      ...

Next: the API docs, and tm1-spring-boot-testcontainers for your tests.

  • Auto-configuration: a Tm1Client bean from tm1.* properties.
  • Session pooling and impersonation: a session per user, from a pool.
  • Your own login: replace the connection details, for example for CAM.
  • Tests: @ServiceConnection for a TM1 container, from tm1-spring-boot-testcontainers.