5
Tôi có ứng dụng Khởi động mùa xuân với spring-boot-starter-remote-shell. Khi tôi đặt kịch bản hello.groovy này, nó in 'hello' và điều đó là OK.Tiêm đậu mùa xuân trong đậu groovy
package commands
import org.crsh.cli.Usage
import org.crsh.cli.Command
class hello {
@Usage("Say Hello")
@Command
def main(InvocationContext context) {
return "hello";
}
}
Nhưng khi tôi cố gắng tiêm một số hạt mùa xuân, nó luôn luôn rỗng.
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";
}
}
Tôi có @ComponentScan(basePackages={"com....", "commands"})
Sẽ dễ dàng hơn để tìm câu trả lời nếu bạn cung cấp ví dụ làm việc tối thiểu trên GitHub chẳng hạn. – Opal