java.sql.SQLException:在centos 7服务器上,URL不能为空

时间:2019-03-18 09:04:41

标签: maven jenkins

我有一台安装了maven的CentOS 7服务器,将我的gitlab源代码构建为jar文件,该构建似乎可以,但是当我尝试执行jar文件时,它显示以下错误消息:

      java.sql.SQLException: The url cannot be null
      at java.sql.DriverManager.getConnection(DriverManager.java:649) ~ 
      [na:1.8.0_191]
        at java.sql.DriverManager.getConnection(DriverManager.java:208) ~ 
     [na:1.8.0_191]
        at 
 org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:308) ~[tomcat-jdbc-8.5.27.jar!/:na]
        at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.27.jar!/:na]
        at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:735) [tomcat-jdbc-8.5.27.jar!/:na]
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:667) [tomcat-jdbc-8.5.27.jar!/:na]
        at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482) [tomcat-jdbc-8.5.27.jar!/:na]
        at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154) [tomcat-jdbc-8.5.27.jar!/:na]
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) [tomcat-jdbc-8.5.27.jar!/:na]
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) [tomcat-jdbc-8.5.27.jar!/:na]
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131) [tomcat-jdbc-8.5.27.jar!/:na]
        at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) [hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]

我试图用STS在Windows 10笔记本电脑中构建jar文件,但效果很好,我可以执行jar文件而没有任何问题。

服务器专家是否缺少任何内容?我很确定SQL连接正常并且我的数据库正在使用MSSQL服务器。

以下是/root/project-name/src/main/resources/application.properties文件中的数据源配置示例:

    app.datasource.url=jdbc:jtds:sqlserver://DB-IP:1433/dbname
    app.datasource.username=dbuser
    app.datasource.password=dbpassword
    app.datasource.pool-size=10

    # Keep the connection alive if idle for a long time (needed in 
    production)

    spring.datasource.testWhileIdle = true
    spring.datasource.validationQuery = SELECT 1
    server.port=8888

我使用的命令是

mvn全新安装

和Java版本

[root@localhost resources]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) Server VM (build 25.191-b12, mixed mode)

0 个答案:

没有答案