Reputation: 1059
I have a small application that doesn't use Spring container. Now there's a need for this application to access a database, just several small queries, nothing complex. Although I can do this with pure JDBC I'd really like to utilize Spring-JDBC library. My concern is whether it can be easily used without bringing in too much Spring into the application. By "too much Spring" I mean having to create spring containers, excessive external library dependencies, etc. Please, advise.
Upvotes: 7
Views: 2767
Reputation: 11802
I'd put Spring JDBC dependency into my project, for example, in case of Apache Ivy:
<dependency org="org.springframework" name="org.springframework.jdbc" rev="3.0.4.RELEASE" conf="src,runtime->runtime"/>
It would resolve all other required dependencies for me.
If you look at the dependency list in SprinSource Enterprise Bundle Repository, you'll see that it requires Core, Beans and Context. You can't get rid of that.
Upvotes: 1
Reputation: 308753
I think you have to have the Spring core JAR and its dependencies, but you're never required to use the bean factory if you don't want to. Sounds like all you want is the JdbcTemplate
. If that's the case, I'd put the spring-jdbc JAR into my CLASSPATH
, build, and keep adding JARs until all the ClassNotFoundExceptions
went away. That would be the minimum set you'd need to use Spring JDBC on its own.
Upvotes: 1