Spring/Spring-Boot学习 答疑

收录学习过程中的小疑问


spring-jdbc和mysql-connector-java之间的区别

  • The MySQL connector java is a JDBC driver provided by MySQL and you must include it in your Java app, if you want your app to talk to a MySQL database.
  • JDBC is a standard API in Java to communicate with a SQL database and each type of database has its own driver that knows how to communicate with the database.
  • On the other hand, Spring JDBC is a convenience tool and an abstraction layer built on top of the JDBC api that allows developers to communicate with SQL databases using their JDBC drivers removing a lot of the boilerplate(模版) code. You don't necessary have to useSpring JDBC`, but it will make your life easier.
  • MySQL connector javaMySQL提供的给Java语言访问MySQL的数据库驱动;
  • JDBC是标准的Java API,是专门用来管理SQL数据库的,JDBC是一个接口,这个接口上可以插上不同的数据库驱动,MySQL connector java只是用来它用来访问MySQL数据库的一种驱动。还有其他的数据库如Oracle, DB2等也提供了驱动给JDBC使用;
  • Spring JDBCSpring包装了JDBC的工具,省去了很多使用JDBC的模版代码;
    所以使用java语言访问 MySQL数据库可以使用原始的JDBC+MySQL connector java, 或者使用更方便的Spring JDBC+MySQL connector java


com.mysql.jdbc.Driver和com.mysql.cj.jdbc.Driver的区别

com.mysql.jdbc.Driver 是 mysql-connector-java 5中的,
com.mysql.cj.jdbc.Driver 是 mysql-connector-java 6中的
参考com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别

@inherited注解

@Inherited 元注解是一个标记注解,@Inherited阐述了某个被标注的类型是被继承的。
如果一个使用了@Inherited修饰的annotation类型被用于一个class,则这个annotation将被用于该class的子类。
参考理解注解中的@Inherited

猜你喜欢

转载自www.cnblogs.com/greatLong/p/11938264.html
今日推荐