druid 配置需要哪些jar包

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了druid 配置需要哪些jar包相关的知识,希望对你有一定的参考价值。

参考技术A <dependencies>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>$spring.version</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>$spring.version</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>$spring.version</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>$spring.version</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>$spring.version</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-ibatis</artifactId>
<version>2.0.8</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.3.0</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.2</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.35</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>$junit.version</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.9.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId>
<version>0.7.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp-spring</artifactId>
<version>0.7.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>proxool</groupId>
<artifactId>proxool</artifactId>
<version>0.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>proxool</groupId>
<artifactId>proxool-cglib</artifactId>
<version>0.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
<scope>test</scope>本回答被提问者采纳

idea配置tomcat,导入jar包,druid连接池配置

这次稍微给大家讲一下idea配置tomcat以及导入jar包和数据库连接池druid的使用,这都是些非常非常基础的东西,大家都可以尝试做一下。在这里多说两句关于编译器事,大家在学习javaweb的时候如果在eclipse和idea两者之间犹豫不决反复横跳的话,一定要多安一个tomcat备用,不要两个编译器同时用一个tomcat(tom会受不了的)。我之前就是用一个tomcat在两个编译器之间反复横跳,结果迎来了全部项目都启动不了的蛋疼,让我享受了一把做男人的快乐,嗯,做男人,真好。

idea配置tomcat,导入jar包,druid连接池配置

扯了这么多,回归正题,首先我们要准备的软件有ideaIU(这玩意社区版不支持web开发,IU版要钱,但是互联网嘛,道高一尺魔高一丈,大家要合理运用搜索工具,给大家附一篇博客

https://blog.csdn.net/qq_40667143/article/details/80476320,可能不一定有用,多在网上找一些方法吧,实在不行IU版有个学生认证可以使用一年,先凑合试试),Tomcat(8或9都可以),jdbc的jar包和druid的jar包(网盘链接在下面)。


链接:https://pan.baidu.com/s/1oJT7gFaXIKwodV9gdsjlvg

提取码:5rhk


首先把tomcat下载好以后要配环境变量,这里我任然选择不要脸的嫖一篇别人的博客,哈哈哈

(https://blog.csdn.net/qq_43252519/article/details/82883708)

然后我们需要在idea上面部署tomcat服务器,首先点击小锤子旁边那个框框(未配置前那里应该是add conficonfigurations)


点进去后会弹出一个框框,点一下左上角那个+,如下:

idea配置tomcat,导入jar包,druid连接池配置

点击后会弹出如下界面:

idea配置tomcat,导入jar包,druid连接池配置

此时的name需要你自行定义(也可以不写),点conficonfigurations会有弹窗,找到你的tomcat目录,点ok,在最下角有时候会有一个错误信息,点一下fix就行。然后点server旁边的deployment,

idea配置tomcat,导入jar包,druid连接池配置

点击+后选第一个,点OK,就可以了,配好后应该像第一张图,会有个猫的标志,点击后会启动tomcat服务器。

接下来说一下导入jar包:首先在web_inf文件夹下创建lib目录,将要导入的jar包放在这个目录下,然后右键jar包,选择add as library,弹窗出来直接点ok

idea配置tomcat,导入jar包,druid连接池配置

就成功导入了。

druid连接池也需要先导入jar包(操作如上),然后在src文件夹里创建一个druid.properties文件,内容如下:

driverClassName=com.mysql.jdbc.Driverurl=jdbc:mysql://localhost:3306/(数据库名)?useUnicode=true&characterEncoding=utf-8username=rootpassword=passwordinitialSize=5maxActive=10minIdle=3maxWait=3000

其中password是你自己的数据库连接密码,对于这些参数感兴趣的朋友可以参考这篇博客(是的我又开始白嫖了哈哈哈哈)

https://blog.csdn.net/chenyu201003/article/details/68489068

接下来新建一个链接类:

主要代码如下:

public static DataSource dataSource; static { InputStream is= Druid_conn.class.getClassLoader().getResourceAsStream("druid.properties"); Properties properties = new Properties(); try { properties.load(is); dataSource = DruidDataSourceFactory.createDataSource(properties); } catch (IOException e) { e.printStackTrace(); }catch (Exception e){ e.printStackTrace(); } } public static Connection getConnection(){ Connection conn = null; try { conn = dataSource.getConnection(); } catch (SQLException e) { e.printStackTrace(); } return conn; }

就ok了,在需要使用数据库连接的地方将getConnection()所在包导入就行。

今天就水到这里了,溜了溜了


以上是关于druid 配置需要哪些jar包的主要内容,如果未能解决你的问题,请参考以下文章

idea配置tomcat,导入jar包,druid连接池配置

mybatis操作oracle需要哪些jar包

使用eclipse 实现spring 框架需要哪些包?

Druid连接池的工具类以及简单代码实现

Druid连接池配置多数据源

一个简单的SpringMVC需要哪些jar包