5
Ho un'applicazione Spring Boot con spring-boot-starter-remote-shell. Quando metto questo ciao.groovy script stampa 'ciao' e va bene.Inject Spring bean in groovy bean
package commands
import org.crsh.cli.Usage
import org.crsh.cli.Command
class hello {
@Usage("Say Hello")
@Command
def main(InvocationContext context) {
return "hello";
}
}
Ma quando provo a iniettare del bean Spring è sempre nullo.
package commands
import org.crsh.cli.Usage
import org.crsh.cli.Command
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import org.springframework.batch.core.launch.JobLauncher
@Component
class hello {
@Autowired
JobLauncher jobLauncher;
@Usage("Say Hello")
@Command
def main(InvocationContext context) {
if(jobLauncher != null){
return "OK";
}else{
return "NULL";
}
return "hello j";
}
}
devo @ComponentScan(basePackages={"com....", "commands"})
Sarebbe più facile trovare una risposta se per esempio si fornisce un esempio di lavoro minimo su GitHub. – Opal