0
我試圖在eclipse Luna
中設置gradle
以獲得簡單的應用程序,但沒有下載任何jar。任何人都可以給我一個我失蹤的想法嗎? 我在命令行運行gradle clean build
併成功編譯: 這是我build.gradle
文件的內容:Spring Boot Gradle設置
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")
}
這是類的與控制器的內容:
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. ";
}
}
這是與主要功能類:
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");
}
}
你有eclipse的gradle插件嗎? –
@ mh-dev是的,我喜歡。我按照以下步驟安裝它:https://pbaris.wordpress.com/2014/08/25/install-gradle-plugin-for-eclipse/。 – user3810317
你是如何將項目添加到eclipse的? –