20201202 王维

学习总结

1 Druid 数据源使用

  1. 导入 druid 的 jar 包
  2. 配置数据源
  3. 添加 servlet 及 filter 配置
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>1.1.10</version>
</dependency>
<bean id="datasource" class="com.alibaba.druid.pool.DruidDataSource">
    <property name="driverClassName" value="${jdbc.driver}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
<!-- 配置监控统计拦截的filters, 以下配置表示 使用StatFilter/Log4JFilter/防
火墙 -->
    <property name="filters" value="stat,log4j,wall" />
</bean>
<!-- 添加druid监控-->
<servlet>
    <servlet-name>DruidStatView</servlet-name>
    <servletclass>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
    <init-param>
<!-- 用户名, 可以不设置-->
        <param-name>loginUsername</param-name>
        <param-value>druid</param-value>
    </init-param>
    <init-param>
<!-- 密码, 可以不设置 -->
        <param-name>loginPassword</param-name>
        <param-value>druid</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>DruidStatView</servlet-name>
    <url-pattern>/druid/*</url-pattern>
</servlet-mapping>
<!-- 添加Web应用等监控-->
<filter>
    <filter-name>DruidWebStatFilter</filter-name>
    <filter-class>com.alibaba.druid.support.http.WebStatFilter</filterclass>
    <init-param>
        <param-name>exclusions</param-name>
        <param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
        </param-value>
    </init-param>
    <init-param>
        <param-name>profileEnable</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>principalCookieName</param-name>
        <param-value>USER_COOKIE</param-value>
    </init-param>
    <init-param>
        <param-name>principalSessionName</param-name>
        <param-value>USER_SESSION</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>DruidWebStatFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

心得体会

今天继续练习了ssm框架整合,完成了模块依赖版本的整合,也练习了单个模块的整合,还进行了Oracle数据库的前期准备,进行了虚拟机的安装和数据库的安装。

标签

评论

© 2021 成都云创动力科技有限公司 蜀ICP备20006351号-1