Grails 3 - Gradle依赖Mysql连接器 [英] Grails 3 - Gradle dependecies Mysql Connector

查看:183
本文介绍了Grails 3 - Gradle依赖Mysql连接器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用grails 3.0.9设置了一个grails应用程序



现在我想添加mysql连接器来连接到mysql数据库。 p>

因此我添加了一个条目到我的build.gradle,但连接器不是由gradle提取的。



<$ p $ (
ext {
grailsVersion = project.grailsVersion
}
仓库{
mavenLocal()
maven {url https://repo.grails.org/grails/core}
}
依赖关系{
classpathorg.grails:grails-gradle-plugin:$ grailsVersion
classpathcom.bertramlabs.plugins:asset-pipeline-gradle:2.5.0
classpathorg.grails.plugins:hibernate:4.3.10.5
classpathmysql:mysql-connector-java: 5.1.37

}

插件{
idio.spring.dependency-management版本0.5.2.RELEASE
}

版本0.1
组nexttext

套用插件:spring -boot
apply plugin:war
apply plugin:asset-pipeline
apply plugin:'eclipse'
apply plugin:'idea'
apply插件:org.grails.grails-web
apply插件:org.grails.grails-gsp

ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}

assets {
minifyJs = true
minifyCss = true
}

repositories {
mavenLocal()
maven {urlhttps://repo.grails.org/grails/core}
}

dependencyManagement {
imports {
mavenBomorg.grails:grails-bom:$ grailsVersion

applyMavenExclusions false
}

依赖关系{
compileorg .bringframework.boot:spring-boot-starter-logging
compileorg.springframework.boot:spring-boot-starter-actuator
compileorg.springframework.boot:spring-boot-autoconfigure
编译org.springframework.boot:sprin g-boot-starter-tomcat
compileorg.grails:grails-dependencies
compileorg.grails:grails-web-boot

compileorg。 grails.plugins:hibernate
compileorg.grails.plugins:cache
compileorg.hibernate:hibernate-ehcache
compileorg.grails.plugins:scaffolding

runtimeorg.grails.plugins:asset-pipeline

testCompileorg.grails:grails-plugin-testing
testCompileorg.grails.plugins: geb

//注意:建议更新为更强大的驱动程序(Chrome,Firefox等)
testRuntime'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44 .0'

consoleorg.grails:grails-console


任务包装(类型:包装器){
gradleVersion = gradleWrapperVersion
}

不知道我做错了什么,但是我得到一个ClassNotFoundException。 p>

解决方案

添加本地gradle安装Intellij似乎解决了这个问题。我认为包含的gradle-wrapper导致了麻烦。所以下载gradle 2.8并将其设置为在Settings - > Build ... - > Build Tools中使用 - > Gradle解决了这个问题。



现在mysql连接器显示在外部库
Gradle:mysql:mysql-connector-java:5.1.37


I have set up a grails app using grails 3.0.9

Now I want to add the mysql connector to bring up an connection to a mysql database.

Therefore I have added an entry to my build.gradle, but the connector is not fetched by gradle.

buildscript {
    ext {
        grailsVersion = project.grailsVersion
    }
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0"
        classpath "org.grails.plugins:hibernate:4.3.10.5"
        classpath "mysql:mysql-connector-java:5.1.37"
    }
}

plugins {
    id "io.spring.dependency-management" version "0.5.2.RELEASE"
}

version "0.1"
group "nexttext"

apply plugin: "spring-boot"
apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"

ext {
    grailsVersion = project.grailsVersion
    gradleWrapperVersion = project.gradleWrapperVersion
}

assets {
    minifyJs = true
    minifyCss = true
}

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
}

dependencyManagement {
    imports {
        mavenBom "org.grails:grails-bom:$grailsVersion"
    }
    applyMavenExclusions false
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-dependencies"
    compile "org.grails:grails-web-boot"

    compile "org.grails.plugins:hibernate"
    compile "org.grails.plugins:cache"
    compile "org.hibernate:hibernate-ehcache"
    compile "org.grails.plugins:scaffolding"

    runtime "org.grails.plugins:asset-pipeline"

    testCompile "org.grails:grails-plugin-testing"
    testCompile "org.grails.plugins:geb"

    // Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
    testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'

    console "org.grails:grails-console"
}

task wrapper(type: Wrapper) {
    gradleVersion = gradleWrapperVersion
}

Don't know what I am doing wrong but I get an ClassNotFoundException.

解决方案

Adding a local gradle installation to Intellij seems to solve the problem. I think that the included gradle-wrapper caused the trouble.

So downloading gradle 2.8 and setting it to use in Settings -> Build... -> Build Tools -> Gradle solved the problem.

Now the mysql connector is showing up under External Libraries Gradle: mysql:mysql-connector-java:5.1.37

这篇关于Grails 3 - Gradle依赖Mysql连接器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆