Eclipse中的Gradle项目构建良好,但Java文件显示编译错误 [英] Gradle project in eclipse builds fine but java files show compilation error

查看:64
本文介绍了Eclipse中的Gradle项目构建良好,但Java文件显示编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个gradle项目。我正在使用 Buildship eclipse插件做为gradle。在我的 build.gradle 文件中,我应用了以下插件-

This is my first gradle project. I am using Buildship eclipse plugin for gradle. In my build.gradle file, I have below plugins applied -

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'

所有相关依赖项的定义如下:

All the relevant dependencies are defined as compile as below -

.
.
compile ("org.hibernate:hibernate-entitymanager:${hibernateVer}")
compile ("org.hibernate:hibernate-core:${hibernateVer}")
compile ("org.hibernate:hibernate-validator:${hibernateValVer}")

compile ("org.slf4j:slf4j-api:${slf4jVer}")
compile ("org.slf4j:slf4j-log4j12:${slf4jVer}")
.
.

该项目也使用tomcatRun命令成功构建并运行。但是,日食显示我的java文件中的导入出现编译错误,表示无法解决依赖项。

The project builds and runs successfully using tomcatRun command as well. But the eclipse is showing compilation errors on my imports in java files, saying that the dependencies can not be resolved.

我尝试了Project-> Clean,然后刷新,但仍然卡住。我该怎么做才能消除这些编译错误?

I tried Project->Clean and then refresh, but still stuck. What can i do to remove these compilation errors? Thanks in advance.

推荐答案

从工作区中删除项目,然后将其作为gradle项目再次导入,为我解决了这个问题。也许在我前进的道路上,我所做的某些事情消除了项目的渐变性质。

Removing the project from workspace and importing it again as a gradle project fixed the issue for me. Maybe somewhere down the path I have done something that has removed the "gradle" nature of the project.

这篇关于Eclipse中的Gradle项目构建良好,但Java文件显示编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆