2016-10-08 3 views
0

Ich habe versucht, gradle in eclipse Luna für eine einfache Anwendung einzurichten, aber keine der Gläser heruntergeladen werden. Kann mir jemand eine Vorstellung davon geben, was mir fehlt? Ich lief gradle clean build in der Befehlszeile und es erfolgreich kompiliert: gradle clean build in workspace folder Dies ist der Inhalt meiner build.gradle Datei:Spring Boot Gradle Setup

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'spring-boot' 

jar { 
    baseName = 'sample' 
    version = '0.1.0' 
} 
repositories { 
    mavenCentral() 
} 
sourceCompatibility = 1.8 
targetCompatibility = 1.8 
dependencies { 
    compile("org.springframework.boot:spring-boot-starter-web") 
} 

Dies ist der Inhalt der Klasse mit dem Controller:

package sample; 

import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RestController; 

@RestController 
public class SampleController { 

    @RequestMapping("/sample") 
    public String sampleIt(){ 
     return "Hello! Welcome to Spring Boot Sample. "; 
    } 
} 

Dies ist die Klasse mit der Hauptfunktion:

package sample; 

import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.context.ApplicationContext; 

@SpringBootApplication 
public class SampleApplication { 

    public static void main(String[] args) { 
     ApplicationContext ctx = SpringApplication.run(SampleApplication.class, args); 
     System.out.println(ctx.getDisplayName()); 

     System.out.println("This is my first Spring Boot Example"); 

    } 

} 
+0

Haben Sie das Gradle-Plugin für Eclipse? –

+0

@ mh-dev Ja, das tue ich. Ich habe es installiert, indem ich die Schritte von dieser Site folge: https://pbaris.wordpress.com/2014/08/25/install-gradle-plugin-for-eclipse/. – user3810317

+0

Wie hast du das Projekt zu Eclipse hinzugefügt? –

Antwort

0

Antwort aus dem Kommentar:

Es ist notwendig, die gradle Plugin und importieren Sie das gradle Projekt anschließend zu installieren. (Vergessen Sie nicht, auf die Schaltfläche "Build Model" zu klicken)

Verwandte Themen