0

Am a total beginner with spring framework and trying to know if it even fits my use case, before investing time learning it.

I'm responsible for a stand alone java project(used as a jar by a server) which basically serves requests from a server, and in turn makes service calls to various internal services. This standalone java project, currently has all of its service calls hard coded. I want to use Spring to inject dependencies so I can make this stuff testable.

I have no idea how spring works. Does it even hold for standalone jars or is it only for 'running applications'?

If I make my standalone project 'spring enabled', when the server uses my jar, will it automagically work by creating beans or is there some requirement from the server side?

4

1 回答 1

1

简而言之,是的,您可以在独立的 jar 应用程序(“控制台应用程序”,如果您愿意的话)中使用 Spring,我们一直在工作。您只需要在应用程序启动时自己创建 ApplicationContext,请参见此处的示例:http: //www.devdaily.com/blog/post/java/load-spring-application-context-file-java-swing-application

这只是我直接从 Google 中提取的一个示例,可能还有很多其他示例。不过,您确实需要至少阅读Spring 文档中的基础知识才能开始使用,否则您可能很快就会碰壁。

于 2012-05-17T11:49:45.130 回答