spring - Spring Cloud Angel.SR4和Grails 3.0.9无法正常工作

标签 spring grails spring-cloud grails-3.0.10 spring-boot-gradle-plugin

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

我正在创建一个Grails项目3.0.10版本,并希望该项目作为Eureka Client运行。我正在使用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


也许你可以帮我

谢谢 !!

最佳答案

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

关于spring - Spring Cloud Angel.SR4和Grails 3.0.9无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34501851/

相关文章:

java - 如果类没有 setter,如何将对象 Autowiring 到 bean

mysql - Spring Hibernate mysql 一对多

java - 如何使用 HibernateDaoSupport 类在 Hibernate 中使用自定义 select 语句

grails - 如何使用Spring Security SAML插件在项目中指定updatePasswordUrl(例如loginFormUrl = '/saml/login')

java - 一直从数据库获取数据后如何解码值

grails - Grails/Groovy:使用grails.plugin.jxl.builder.ExcelBuilder格式化列

grails - Grails上的Spring Security和带有领域的Tomcat Security

java - Spring @EnableResourceServer 与 @EnableOAuth2Sso

spring-boot - @Refreshscope 与数据源配置

java - Spring Boot应用程序未与Cloud Config Server连接