1

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

user1796942
  • 3,228
  • 5
  • 29
  • 38

3 Answers3

6

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.

Jean-Philippe Bond
  • 10,089
  • 3
  • 34
  • 60
2

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.

Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
0

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.

Community
  • 1
  • 1
melbyts
  • 189
  • 1
  • 5