Maven JdbcTemplate 排除

Maven JdbcTemplate exclusion

我想使用 JdbcTemplate 查询一些非常简单的值:

String sql = "SELECT NAME FROM CUSTOMER WHERE CUST_ID = ?";
String name = (String)getJdbcTemplate().queryForObject(
        sql, new Object[] { custId }, String.class);

所以我将流动条目添加到我的 pom:

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>4.3.7.RELEASE</version>
    </dependency>

我看到添加了其他 Jars

  1. spring-tx-4.3.7.RELEASE.jar
  2. spring-beans-4.3.7.RELEASE.jar
  3. spring-core-4.3.7.RELEASE.jar

我想尽量减少与主机应用程序的 jar 冲突,并减少我的代码占用空间,
从这个列表中,我可以排除什么并仍然让 JdbcTemplate 工作?

我不会让您失望的,但是... none 其中有排他性。需要所有提到的罐子。

您可以访问 dependency respository site itself 进行检查。您可以在 "Compile Dependencies" 列表中找到所有这些(甚至更多)。

或者在项目根目录下执行mvn dependency:tree -Dverbose -Dincludes=org.springframework:spring-core,org.springframework:spring-tx,org.springframework:spring-beans自行验证。

命令应该给你这样的东西:

[INFO] \- org.springframework:spring-jdbc:jar:4.3.7.RELEASE:compile
[INFO]    +- org.springframework:spring-beans:jar:4.3.6.RELEASE:compile (version managed from 4.3.7.RELEASE)
[INFO]    |  \- (org.springframework:spring-core:jar:4.3.6.RELEASE:compile - version managed from 4.3.7.RELEASE; omitted for duplicate)
[INFO]    +- org.springframework:spring-core:jar:4.3.6.RELEASE:compile
[INFO]    \- org.springframework:spring-tx:jar:4.3.6.RELEASE:compile (version managed from 4.3.7.RELEASE)
[INFO]       +- (org.springframework:spring-beans:jar:4.3.6.RELEASE:compile - version managed from 4.3.7.RELEASE; omitted for duplicate)
[INFO]       \- (org.springframework:spring-core:jar:4.3.6.RELEASE:compile - version managed from 4.3.7.RELEASE; omitted for duplicate)