公司项目启动的时候连接数据库问题

最近在启动公司项目的时候,在执行DB.getInfo();这个方法的时候总是提示查询不到数据,自己查看后台也没有报错,当时真的很郁闷,可是数据库中命名是有这条数据的,

use mgudb
SELECT * from lduser where 1=1 and usercode='001';--是能够查询到结果的。

打印出来的日志,自己全局搜索也没有mgudat这个数据库的字样,都是mgudb这个数据库,明明是对着的。这究竟是怎么回事。

所以这肯定是数据库连接的地址不对。(ip不对)

于是自己找到了框架的配置文件:(并做了相应的修改)

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <project xmlns="http://maven.apache.org/POM/4.0.0"
  3          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5     <modelVersion>4.0.0</modelVersion>
  6 
  7     <groupId>com.sinosoft</groupId>
  8     <artifactId>lis7-framework</artifactId>
  9     <name>lis7-mgu</name>
 10     <packaging>pom</packaging>
 11     <version>1.0-SNAPSHOT</version>
 12     <modules>
 13         <module>lis-schema-core</module>
 14         <module>lis-pubfun</module>
 15         <module>lis-service</module>
 16         <module>lis-base</module>
 17         <module>lis-utility</module>
 18         <module>lis-service-schema</module>
 19         <module>lis-starters</module>
 20         <!--        <module>lis-calculator</module>-->
 21         <!--<module>lis-product</module>-->
 22         <module>lis-f1print</module>
 23         <module>lis-workflow-engine</module>
 24         <module>lis-publock</module>
 25         <module>lis-easyscan5</module>
 26     </modules>
 27     <scm>
 28         <url>git@cloud.sinosoft-open.com:fwd-claim/lis7-framework.git</url>
 29     </scm>
 30 
 31     <properties>
 32         <!--Spring Boot -->
 33         <springboot.version>2.0.1.RELEASE</springboot.version>
 34         <!--项目字符集-->
 35         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 36         <project.build.resoreceEncoding>UTF-8</project.build.resoreceEncoding>
 37         <!--JDK版本-->
 38         <maven.compiler.target>1.8</maven.compiler.target>
 39         <maven.compiler.source>1.8</maven.compiler.source>
 40         <!-- 工具类 -->
 41         <commons.beanutils.version>1.8.3</commons.beanutils.version>
 42         <commons.lang.verions>2.3</commons.lang.verions>
 43 
 44         <dom4j.version>1.6.1</dom4j.version>
 45         <xalan.version>2.7.0</xalan.version>
 46         <jdom.version>1.1.3</jdom.version>
 47         <ehcache-core.version>2.5.0</ehcache-core.version>
 48         <poi.version>3.8</poi.version>
 49         <ojdbc.version>12.1.0.2</ojdbc.version>
 50         <jimi.version>1.0</jimi.version>
 51         <f1j9swing.version>1.0</f1j9swing.version>
 52         <sinomail.version>1.0</sinomail.version>
 53         <mina.version>2.0.13</mina.version>
 54         <reflectasm.version>1.07</reflectasm.version>
 55         <servlet.version>4.0.1</servlet.version>
 56         <ejb.version>3.0</ejb.version>
 57     </properties>
 58 
 59     <repositories>
 60         <repository>
 61             <id>releases</id>
 62             <name>releases</name>
 63             <url>http://47.103.84.217:8081/repository/sinosoft-gbg-repository-group/</url>
 64             <releases>
 65                 <enabled>true</enabled>
 66                 <updatePolicy>never</updatePolicy>
 67                 <checksumPolicy>warn</checksumPolicy>
 68             </releases>
 69             <snapshots>
 70                 <enabled>true</enabled>
 71                 <updatePolicy>always</updatePolicy>
 72                 <checksumPolicy>warn</checksumPolicy>
 73             </snapshots>
 74         </repository>
 75         <repository>
 76             <id>ICS-Repositories</id>
 77             <name>ICS-Repositories</name>
 78             <url>http://124.204.68.210:11133/repository/lis-group</url>
 79             <releases>
 80                 <enabled>true</enabled>
 81                 <updatePolicy>never</updatePolicy>
 82                 <checksumPolicy>warn</checksumPolicy>
 83             </releases>
 84             <snapshots>
 85                 <enabled>true</enabled>
 86                 <updatePolicy>always</updatePolicy>
 87                 <checksumPolicy>warn</checksumPolicy>
 88             </snapshots>
 89         </repository>
 90     </repositories>
 91 
 92     <!--依赖管理-->
 93 
 94     <dependencyManagement>
 95         <dependencies>
 96 
 97             <dependency>
 98                 <groupId>org.springframework.boot</groupId>
 99                 <artifactId>spring-boot-dependencies</artifactId>
100                 <version>${springboot.version}</version>
101                 <type>pom</type>
102                 <scope>import</scope>
103             </dependency>
104 
105             <dependency>
106                 <groupId>com.sinosoft</groupId>
107                 <artifactId>lis7-framework-dependencies</artifactId>
108                 <version>1.0-SNAPSHOT</version>
109                 <type>pom</type>
110                 <scope>import</scope>
111             </dependency>
112             <!--导入导出excel依赖 by jhy-->
113             <!--poi-->
114             <dependency>
115                 <groupId>org.apache.poi</groupId>
116                 <artifactId>poi</artifactId>
117                 <version>3.8</version>
118             </dependency>
119             <dependency>
120                 <groupId>org.apache.poi</groupId>
121                 <artifactId>poi-ooxml</artifactId>
122                 <version>3.8</version>
123             </dependency>
124             <dependency>
125                 <groupId>org.apache.poi</groupId>
126                 <artifactId>poi-ooxml-schemas</artifactId>
127                 <version>3.8</version>
128             </dependency>
129         </dependencies>
130     </dependencyManagement>
131 
132     <!--默认本地模式, 需要本地新建mysql数据库-->
133     <profiles>
134         <!--<profile>
135             <id>dev</id>
136 
137             <properties>
138                 <datasource.type>org.apache.tomcat.jdbc.pool.DataSource</datasource.type>
139                 <datasource.url>jdbc:mysql://47.103.144.156:3306/mgudb</datasource.url>
140                 <datasource.username>root</datasource.username>
141                 <datasource.password>root123456</datasource.password>
142                 <datasource.driver-class-name>com.mysql.jdbc.Driver</datasource.driver-class-name>
143                 <datasource.validationQuery>select 1 </datasource.validationQuery>
144                 <datasource.tomcat.test-while-idle>true</datasource.tomcat.test-while-idle>
145                 <datasource.tomcat.test-on-borrow>true</datasource.tomcat.test-on-borrow>
146             </properties>
147         </profile>-->
148         <profile>
149             <id>dat</id>
150             <activation>
151                 <activeByDefault>true</activeByDefault>
152             </activation>
153             <properties>
154                  <datasource.type>org.apache.tomcat.jdbc.pool.DataSource</datasource.type>
155                 <datasource.url>jdbc:mysql://47.103.144.156:3306/mgudb</datasource.url>
156                 <datasource.username>root</datasource.username>
157                 <datasource.password>root123456</datasource.password>
158                 <datasource.driver-class-name>com.mysql.jdbc.Driver</datasource.driver-class-name>
159                 <datasource.validationQuery>select 1 </datasource.validationQuery>
160                 <datasource.tomcat.test-while-idle>true</datasource.tomcat.test-while-idle>
161                 <datasource.tomcat.test-on-borrow>true</datasource.tomcat.test-on-borrow>
162             </properties>
163         </profile>
164        <!-- <profile>
165             <id>uat</id>
166             <activation>
167                 <activeByDefault>true</activeByDefault>
168             </activation>
169             <properties>
170                  <datasource.type>org.apache.tomcat.jdbc.pool.DataSource</datasource.type>
171                 <datasource.url>jdbc:mysql://47.103.153.87:33306/mgudb</datasource.url>
172                 <datasource.username>sinosoft</datasource.username>
173                 <datasource.password>Xay4EyHJyeY+n7IzNc7D</datasource.password>
174                 <datasource.driver-class-name>com.mysql.jdbc.Driver</datasource.driver-class-name>
175                 <datasource.validationQuery>select 1 </datasource.validationQuery>
176                 <datasource.tomcat.test-while-idle>true</datasource.tomcat.test-while-idle>
177                 <datasource.tomcat.test-on-borrow>true</datasource.tomcat.test-on-borrow>
178             </properties>
179         </profile>-->
180     </profiles>
181 
182 
183     <!--构件支持-->
184     <build>
185         <resources>
186             <resource>
187                 <directory>${basedir}/src/main/resources</directory>
188                 <filtering>true</filtering>
189                 <includes>
190                     <include>**/application*.properties</include>
191                     <include>**/bootstrap.properties</include>
192                 </includes>
193             </resource>
194             <resource>
195                 <directory>${basedir}/src/main/resources</directory>
196                 <excludes>
197                     <exclude>**/application*.properties</exclude>
198                     <exclude>**/bootstrap.properties</exclude>
199                 </excludes>
200             </resource>
201         </resources>
202         <pluginManagement>
203             <plugins>
204                 <plugin>
205                     <groupId>org.apache.maven.plugins</groupId>
206                     <artifactId>maven-resources-plugin</artifactId>
207                     <configuration>
208                         <delimiters>
209                             <delimiter>@</delimiter>
210                         </delimiters>
211                         <useDefaultDelimiters>false</useDefaultDelimiters>
212                     </configuration>
213                 </plugin>
214                 <plugin>
215                     <groupId>org.springframework.boot</groupId>
216                     <artifactId>spring-boot-maven-plugin</artifactId>
217                     <version>${springboot.version}</version>
218                     <executions>
219                         <execution>
220                             <goals>
221                                 <goal>repackage</goal>
222                             </goals>
223                             <configuration>
224                                 <mainClass>com.sinosoft.LisApplication</mainClass>
225                                 <finalName>${project.artifactId}</finalName>
226                             </configuration>
227                         </execution>
228                     </executions>
229                 </plugin>
230             </plugins>
231         </pluginManagement>
232         <plugins>
233             <plugin>
234                 <artifactId>maven-war-plugin</artifactId>
235                 <configuration>
236                     <failOnMissingWebXml>false</failOnMissingWebXml>
237                 </configuration>
238             </plugin>
239         </plugins>
240     </build>
241     <distributionManagement>
242         <snapshotRepository>
243             <id>ics-snapshots</id>
244             <name>ICS snapshots</name>
245             <url>http://124.204.68.210:11133/nexus/content/repositories/central-cloud-snapshot/</url>
246         </snapshotRepository>
247         <repository>
248             <id>ics-releases</id>
249             <name>ICS releases</name>
250             <url>http://124.204.68.210:11133/nexus/content/groups/lis-group/</url>
251         </repository>
252     </distributionManagement>
253 
254 </project>

从上面不难看出来连接数据库的配置<profile>节点配置有多个,所以,程序是一个一个执行的,所以下面的会将上面的覆盖掉,所以我将其他的注释掉了,只剩下一个节点,并且配置成自己数据库的连接ip以及数据库的名称。这样就可以了。

 

上一篇:偶遇递归树


下一篇:洛谷 P1108 低价购买(LIS,统计方案数)