在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数据库。