Spring -JDBC as a standalone library

I have a small application that does not use the Spring container. Now this application requires access to the database, just a few small queries, nothing complicated. Although I can do this with pure JDBC, I would really like to use the Spring -JDBC library. My concern is whether it can be easily used without introducing too much Spring into the application. By "too much Spring" I mean creating Spring containers, excessive library external dependencies, etc. Please advise.

+6
source share
2 answers

I think you should have a basic Spring JAR and its dependencies, but you will never need to use a bean factory if you don't want to. It looks like all you need is a JdbcTemplate . If so, I put the spring -jdbc JAR in my CLASSPATH , built and continued to add the JAR until all ClassNotFoundExceptions are gone. This will be the minimum set that you will need to use Spring JDBC on your own.

+1
source

I would put a Spring JDBC dependency in my project, for example in the case of Apache Ivy:

 <dependency org="org.springframework" name="org.springframework.jdbc" rev="3.0.4.RELEASE" conf="src,runtime->runtime"/> 

He will allow me all the other necessary dependencies.

If you look at the list of dependencies in the SprinSource Enterprise Bundle Repository , you will see that it requires Core, Beans, and Context. You cannot get rid of it.

+1
source

Source: https://habr.com/ru/post/900186/


All Articles