CPS-2480 Multiple base package
CPS-2480: Multiple base packageIn Progress
Description:
As a plugin developer I want to use multiple base package in NCMP-CPS jar.
Affected version:
CPS 3.5.4
Expected behavior:
I want to configure the base packages with the spring.component.scan variable from the application.yaml .
Impact:
It affects the Spring base application.
Possible solution:
Use ComponentScan annotation
always put your ComponentScan annotation after SpringBootApplication, because the SpringBootApplication will load the configuration.
the ComponentScan annotation will override the original package, so when you want some classes from the original you should add them too.
you can use multiple package with ";": @ComponentScan(basePackages = "my.package.one;my.package.two")
you can use configuration variables and default: @ComponentScan(basePackages = "${spring.component.scan:<my.default.package>}")
Example:
package com.myapp.deff.pckg;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@ComponentScan(basePackages = "${spring.component.scan:com.myapp.deff.pckg}")
public class Application {
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}
Investigation:
Adding ComponentScan to application.java:
@EnableRetry
@SpringBootApplication
@ComponentScan(basePackages = "org.onap.cps")
public class Application {
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}
Failure from mvn clean install:
Caused by: org.springframework.expression.spel.SpelParseException: Expression [${cps.tracing.enabled} && 'grpc'.equals('${cps.tracing.exporter.protocol}')] @1: EL1041E: After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
Further Investigation:
String “org.onap.cps “ not spel compliant.
Change to spel compliant variable:
Failure from mvn clean install:
Error starting docker container