Unable to query a db from gradle build script

后端 未结 2 1536
春和景丽
春和景丽 2021-01-14 19:07

I am trying to query a db from within a gradle script task. I started with a groovy script to verify the code

import groovy.sql.Sql

this.class.classLoader.r         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-14 19:47

    It appears that your net.sourceforge.jtds.jdbc.Driver is not available. This is likely because of an issue with your path in

    buildscript {
        dependencies {
            classpath files('..../jtds-1.2.2.jar')
        }
    }
    

    The path you provide to classpath files( path ) needs to be a relative path to the root of your gradle project directory. I'd suggest moving your jtds jar into the libs directory, and taking a look at this doc: https://docs.gradle.org/current/userguide/dependency_management.html#sub:file_dependencies

    Also, the jtds jar is on the maven repo, why not use that instead of a local jar? The beauty of build tools like gradle and maven is that you do not need to locally store or manage many popular jars.

提交回复
热议问题