user1796942
user1796942

Reputation: 3528

Does it make sense to use Java Web frameworks in non-web projects?

I am working on a machine learning library and I need a stopwatch to measure execution time for a method. It turns out Spring has a nice one, but does it make sense to use Spring for a non-web project? The good side is of course reusing code, but any downsides?

Thanks

Upvotes: 1

Views: 270

Answers (3)

Jean-Philippe Bond
Jean-Philippe Bond

Reputation: 10649

Spring isn't just made for Web application. Spring MVC is the request-based framework that you normally used for web application. Now, if you only want the stopwatch utilities, nothing prevents you to only include the spring-core jar in your project.

Upvotes: 6

melbyts
melbyts

Reputation: 189

I've seen some Apache projects clone a few methods (or classes) from other Apache projects just to avoid adding a jar dependency when very specific functionality is all that is needed.

An alternative to including spring could be to use a more general purpose library. Two suggestions that are made here are Google Guava and Apache Commons Lang. I use both and the odds of finding other useful general purpose utilities in those projects is high.

Upvotes: 0

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340763

Spring is not a web framework. Spring MVC sub-project is. Also Spring support multiple other web frameworks.

That being said you are free to use Spring IoC, AOP, persistence, etc. in desktop, standalone applications. I do it every day.

Upvotes: 2

Related Questions