error: cannot find symbol - when new class is added tand imported in an existing gradle project in IntelliJ IDEA

error: cannot find symbol - when new class is added tand imported in an existing gradle project in IntelliJ IDEA

我必须使用现有的 java 代码库,该代码库使用 gradle。我必须创建一个新的 class 并将其导入现有的 class。当我 运行 gradle buildgradle bootRun 它给出以下错误并且构建失败。

error: cannot find symbol

import com.someservice.generic.model.SomeNewClass;

                                ^   

symbol: class SomeNewClass

location: package com.someservice.generic.model

Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':compileJava'.

    Compilation failed; see the compiler error output for details.

我的新 class 如下所示,

package com.someservice.generic.model;

public class SomeNewClass {


}

我将其导入为

import com.someservice.generic.model.RUnregPatient;

我提到了以下问题

Getting "cannot find Symbol" in Java project in Intellij

Can't compile java class in Intellij Idea due to "cannot find symbol class X" error

并尝试重新导入、无效缓存并重新启动,按照建议重建。 None 其中对我有用。

删除新的 class 文件并创建另一个文件以某种方式解决了这个问题。