我想创建spring控制台应用程序(从命令行运行maven,例如:mvn exec:java -Dexec.mainClass ="package.MainClass").
这个应用程序我想要一些服务和dao层.我知道如何为Web应用程序执行此操作,但我还没有找到有关如何在控制台应用程序中执行操作的任何信息(可能使用Swing).
我正在尝试创建类似的东西:
public interface SampleService {
public String getHelloWorld();
}
@Service
public class SampleServiceImpl implements SampleService {
public String getHelloWorld() {
return "HelloWorld from Service!";
}
}
public class Main {
@Autowired
SampleService sampleService;
public static void main(String [] args) {
Main main = new Main();
main.sampleService.getHelloWorld();
}
}
Run Code Online (Sandbox Code Playgroud)
可能吗?我能找到一个如何做的例子吗?