0

也许你可以帮我解决这个问题:

我正在创建一个 Grails 项目版本 3.0.10,并希望该项目作为 Eureka 客户端工作。我正在使用 Spring Boot 1.3.1.RELEASE 并且我正在尝试使用 Spring Cloud Angel.SR4 版本。

我有一个运行良好的 Java 项目,但是当尝试应用依赖项并运行我的 Grails 应用程序时,它会引发一些问题:

这是我用于项目的 gradle.build 文件:

buildscript {
    ext {
        grailsVersion = project.grailsVersion
		// I have added this line
		springBootVersion = '1.3.1.RELEASE'
    }
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:hibernate:4.3.10.5"
		
    }
}

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

version "0.1"
group "demograilsclient"

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

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

repositories {
	// I have added those two lines
	mavenCentral()
	jcenter()
	
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
	
	// I have added those two lines
	maven { url "https://repo.spring.io/snapshot" }
	maven { url "https://repo.spring.io/milestone" }
}

dependencyManagement {
    imports {
        mavenBom "org.grails:grails-bom:$grailsVersion"
		// I have added this line
		mavenBom 'org.springframework.cloud:spring-cloud-starter-parent:Angel.SR4'
    }
    applyMavenExclusions false
}

dependencies {
	
	// Spring cloud dependencies
	compile("org.springframework.cloud:spring-cloud-starter-config")
	compile("org.springframework.cloud:spring-cloud-starter-eureka")
	
	// not modified
    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-plugin-url-mappings"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-datasource"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-plugin-async"
    compile "org.grails:grails-web-boot"
    compile "org.grails:grails-logging"

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

    runtime "com.h2database:h2"

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

    console "org.grails:grails-console"
}

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

我的 Application.yml 是:

server:
  port: 0
  
info:
  component: Grails App
  
eureka:
  instance:
    lease-renewal-interval-in-seconds: 10
    metadata-map:
      instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${random.value}}}
  client:
    registry-fetch-interval-seconds: 5
    service-url:
      defaultZone: http://localhost:8761/eureka/

---



grails:
    profile: web-api
    codegen:
        defaultPackage: demograilsclient
info:
    app:
        name: '@info.app.name@'
        version: '@info.app.version@'
        grailsVersion: '@info.app.grailsVersion@'
spring:
    groovy:
        template:
            check-template-location: false
 

.....
... contine >>

grails 框架用来启动应用程序的主类是这样的:

package demograilsclient

import grails.boot.GrailsApp
import grails.boot.config.GrailsAutoConfiguration

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.cloud.netflix.eureka.EnableEurekaClient


@SpringBootApplication
@EnableEurekaClient
class Application extends GrailsAutoConfiguration {
    static void main(String[] args) {
        GrailsApp.run(Application, args)
    }
}

当我执行时:

grails run-app

它抛出以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootRun'.
> A problem occurred starting process 'command 'C:\program files\Java\jdk1.8.0_6
0\bin\java.exe''

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 20.374 secs

也许你可以帮助我,

谢谢 !!

4

1 回答 1

1

Angel.* 和 Spring Boot 1.3.x 不兼容。

于 2015-12-28T23:36:36.743 回答