Plain NILS4Spring

If you don’t want to use the spring-boot-starter artifact you can use NILS4Spring also. But there is a little more configuration needed.

Add to your project

The easiest way to include NILS4Spring as dependency is using a build tool like Maven or Gradle.

Maven

Add the nils4spring dependency:

<dependency>
  <groupId>com.codepulsar.nils</groupId>
  <artifactId>nils4spring</artifactId>
  <version>1.1.0</version>
</dependency>

Add one of the NILS-Adapter implementations (See here).

Gradle

Add the nils4spring dependency:

implementation group: 'com.codepulsar.nils', name: 'nils4spring', version: '1.1.0'

Add one of the NILS-Adapter implementations (See here).

Configuration

To prepare NILS to be used by Spring, you have to perform the following steps:

  1. Add the NilsSpringIntegrationConfiguration to the configuration of the application.

  2. Define a Bean "nilsConfig" providing a NilsConfig for the used NILS adapter.

import com.codepulsar.nils.adapter.rb.ResourceBundleAdapterConfig;
import com.codepulsar.nils.api.NilsConfig;
import com.codepulsar.nils.integration.spring.configuration.NilsSpringIntegrationConfiguration;

@Configuration
@Import(NilsSpringIntegrationConfiguration.class) (1)
@ComponentScan("com.codepulsar.nilsexamples.springintegration.components")
public class DemoConfiguration {

  @Bean
  public NilsConfig<?> nilsConfig() { (2)
    return ResourceBundleAdapterConfig.init(this);
  }
}
1 Import the NilsSpringIntegrationConfiguration
2 Define a Bean nilsConfig

Now you can use NILS in your application. See here for an example.