I ve a "core" application how I want to be "pluginable", so I write some interface and relatives empty bean just to "holding the place"
Project 1 Void Bean
public class VoidDirectiveWriter implements DirectiveWriter {
private org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(VoidDirectiveWriter.class);
@Override
public void writeDirective(InputStream directive, Date... ts) {
log.info("do-nothing");
}
}
Project1 Endpoint file
..
@Autowired
private DirectiveWriter directiveWriter;
..
Project1 Configuration file
@Configuration
public class PackageBundleBeanDefinition {
@Bean
public DirectiveWriter getDirectiveWriter() {
return new VoidDirectiveWriter();
}
}
so, I build the plugin-project with those pieces of codes:
Project 2 not-void Bean
public class ScsperfWriter implements DirectiveWriter {
@Override
public void writeDirective(InputStream is, Date... ts) {
do stuff
}
}
Project 2 configuration file
@Configuration
public class ScsperBeanDefinition {
@Primary
@Bean
public DirectiveWriter getDirectiveWriter() {
return new ScsperfWriter();
}
}
I use Eclipse, if I try to run core project on its own all works fine (void bean trigger), if I try to add the plugin jar build via maven at the project-1 classpath all works as I aspect ( ScsperfWriter bean trigger ) but when i try to run them out of the developement environement via script java.lang.ClassNotFoundException appear. If I try to remove plugins folder from classpath all work fine ( void bean trigger )
this is the script
@echo off
set cp="plugins\pb-report-scsperf.jar;bin\poc-spring-e1packagebundle.jar"
rem set cp="bin\poc-spring-e1packagebundle.jar"
set java_exe=java
set log4j2_config=config\log4j.xml
set application_config=config\application.properties
java -cp %cp% -Dlogging.config=%log4j2_config% -Dloader.main=it.m2sc.PackageBundle org.springframework.boot.loader.PropertiesLauncher --application.properties=%application_config%
can anyone help me ? sorry for my english, i'm in rush !