发表于: 2025-07-07 20:32:38

0 7


今天完成的事情:(一定要写非常细致的内容,比如说学会了盒子模型,了解了Margin)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mybatis="http://mybatis.org/schema/mybatis-spring"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context
      https://www.springframework.org/schema/context/spring-context.xsd
      http://mybatis.org/schema/mybatis-spring
      http://mybatis.org/schema/mybatis-spring.xsd">

<!-- 组件扫描 -->
   <context:component-scan base-package="org.example.service"/>
<mybatis:scan base-package="org.example.mapper"/>

<!-- 数据源配置 -->
   <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<!-- 基础配置(与图片中一致) -->
       <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
<property name="url"
                 value="jdbc:mysql://localhost:3306/run?useSSL=false&amp;allowPublicKeyRetrieval=true&amp;serverTimezone=UTC&amp;characterEncoding=utf8"/>
<property name="username" value="root"/>
<property name="password" value="199410"/>


<!-- 连接池核心参数(根据图片中的项目规模推荐) -->
       <property name="initialSize" value="5"/> <!-- 初始化连接数 -->
       <property name="maxActive" value="50"/> <!-- 最大连接数 -->
       <property name="maxWait" value="5000"/> <!-- 获取连接超时时间(毫秒) -->
       <property name="timeBetweenEvictionRunsMillis" value="60000"/> <!-- 检测间隔 -->
       <property name="minEvictableIdleTimeMillis" value="300000"/> <!-- 最小空闲时间 -->

       <!-- 连接有效性检测 -->
       <property name="validationQuery" value="SELECT 1"/>
<property name="testWhileIdle" value="true"/>
<property name="testOnBorrow" value="true"/>

<!-- 监控统计(配合图片中的service层使用) -->
       <property name="filters" value="stat,wall"/>
</bean>
<!-- 添加视图解析器 -->
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>

<!-- 确保扫描Controller-->
   <context:component-scan base-package="org.example.controller"/>
<!-- MyBatis SqlSessionFactory -->
   <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<property name="mapperLocations" value="classpath:mapper/*.xml"/>
</bean>

<!-- Nginx日志路径配置(可选) -->
   <bean id="nginxConfig" class="org.example.config.NginxConfig">
<property name="logPath" value="E:/nginx/logs/access.log"/>
</bean>
</beans>

明天计划的事情:(一定要写非常细致的内容)
遇到的问题:(遇到什么困难,怎么解决的)
收获:(通过今天的学习,学到了什么知识)


返回列表 返回列表
评论

    分享到