命名冲突的问题
- jdbc.properties的命名冲突:${username}取到本地用户名
- mysql拒绝访问
处理前
-
jdbc.properties
driverClassName=com.mysql.cj.jdbc.Driver url=jdbc:mysql://192.168.100.104:3306/db_maventest_allinone?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true&serverTimezone=UTC&useSSL=false username=root password=123456 initialSize=10 maxActive=20 maxWait=10000
-
spring-mybatis.xml
<!-- 数据源 --> <bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="username" value="${username}" /> <property name="password" value="${password}"/> <property name="url" value="${url}"/> <property name="driverClassName" value="${driverClassName}"/> <property name="initialSize" value="${initialSize}"/> <property name="maxActive" value="${maxActive}"/> <property name="maxWait" value="${maxWait}"/> </bean>
处理后
-
jdbc.properties
jdbc.driverClassName=com.mysql.cj.jdbc.Driver jdbc.url=jdbc:mysql://192.168.100.104:3306/db_maventest_allinone?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true&serverTimezone=UTC&useSSL=false jdbc.username=root jdbc.password=123456 jdbc.initialSize=10 jdbc.maxActive=20 jdbc.maxWait=10000
-
spring-mybatis.xml
<!-- 数据源 --> <bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}"/> <property name="url" value="${jdbc.url}"/> <property name="driverClassName" value="${jdbc.driverClassName}"/> <property name="initialSize" value="${jdbc.initialSize}"/> <property name="maxActive" value="${jdbc.maxActive}"/> <property name="maxWait" value="${jdbc.maxWait}"/> </bean>