数据库配置文件-默认数据库连接设置

在pom.xml文件中需要修改的节点

复制代码
 1  <!--默认本地模式, 需要本地新建mysql数据库-->
 2     <profiles>
 3         <profile>
 4             <id>dev</id>
 5             <activation>
 6                 <activeByDefault>true</activeByDefault>
 7             </activation>
 8             <properties>
 9                 <datasource.type>org.apache.tomcat.jdbc.pool.DataSource</datasource.type>
10                 <datasource.url>jdbc:mysql://47.103.144.156:3306/mgudb</datasource.url>
11                 <datasource.username>root</datasource.username>
12                 <datasource.password>root123456</datasource.password>
13                 <datasource.driver-class-name>com.mysql.jdbc.Driver</datasource.driver-class-name>
14                 <datasource.validationQuery>select 1 </datasource.validationQuery>
15                 <datasource.tomcat.test-while-idle>true</datasource.tomcat.test-while-idle>
16                 <datasource.tomcat.test-on-borrow>true</datasource.tomcat.test-on-borrow>
17             </properties>
18         </profile>
19         <profile>
20             <id>dat</id>
21             <properties>
22                 <datasource.type>org.apache.tomcat.jdbc.pool.DataSource</datasource.type>
23                 <datasource.url>jdbc:mysql://47.103.144.156:3306/mgudat</datasource.url>
24                 <datasource.username>root</datasource.username>
25                 <datasource.password>root123456</datasource.password>
26                 <datasource.driver-class-name>com.mysql.jdbc.Driver</datasource.driver-class-name>
27                 <datasource.validationQuery>select 1 </datasource.validationQuery>
28                 <datasource.tomcat.test-while-idle>true</datasource.tomcat.test-while-idle>
29                 <datasource.tomcat.test-on-borrow>true</datasource.tomcat.test-on-borrow>
30             </properties>
31         </profile>
32         <profile>
33             <id>uat</id>
34             <properties>
35                 <datasource.type>org.apache.tomcat.jdbc.pool.DataSource</datasource.type>
36                 <datasource.url>jdbc:mysql://47.103.153.87:33306/mgudb</datasource.url>
37                 <datasource.username>sinosoft</datasource.username>
38                 <datasource.password>Xay4EyHJyeY+n7IzNc7D</datasource.password>
39                 <datasource.driver-class-name>com.mysql.jdbc.Driver</datasource.driver-class-name>
40                 <datasource.validationQuery>select 1 </datasource.validationQuery>
41                 <datasource.tomcat.test-while-idle>true</datasource.tomcat.test-while-idle>
42                 <datasource.tomcat.test-on-borrow>true</datasource.tomcat.test-on-borrow>
43             </properties>
44         </profile>
45     </profiles>
复制代码

其中关键节点名称设置:

<activeByDefault>true</activeByDefault>
这样就会默认连接dev数据库。

posted on   ~码铃薯~  阅读(843)  评论(0编辑  收藏  举报

编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示