写了个 demo ,引了个 okhttp 的依赖,但 ide 里面老是红色报错说找不到,但 gradle build 却可以通过。 好烦啊 o(>< )o 什么提示都没有还不如记事本,不知道该怎么解决。
项目有两个子项目
root | backend | front
root 的 builde.gradle
buildscript { ext { springBootVersion = '1.4.0.RELEASE' } repositories { jcenter() maven { url "http://repo.spring.io/snapshot" } maven { url "http://repo.spring.io/milestone" } mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } subprojects { apply plugin: 'spring-boot' apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' repositories { jcenter() maven { url "http://repo.spring.io/snapshot" } maven { url "http://repo.spring.io/milestone" } mavenCentral() } dependencies { testCompile 'junit:junit:4.12' compile('org.springframework.boot:spring-boot-starter') compile("org.springframework.boot:spring-boot-starter-web") compile 'com.squareup.okhttp3:okhttp:3.4.1' compile 'org.mousio:etcd4j:2.12.0' testCompile('org.springframework.boot:spring-boot-starter-test') } version = '1.0' jar { manifest.attributes provider: 'gradle' } }
子项目的 build.gradle
sourceCompatibility = 1.8 targetCompatibility = 1.8 jar { baseName = 'front' version = '0.0.1-SNAPSHOT' } eclipse { classpath { containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' } }
![]() | 1 wahyd4 2016-08-22 17:40:28 +08:00 ![]() 添加个 gradle idea plugin 在 build.gradle 里面,然后执行 gradle idea 就好了。 |