java - import static: 'MainController' 不是可以解析的符号
问题描述
我有一个要从中导入公共静态方法 (getModPart()) 的类。getModePart() 的来源是 MainController。以下是 MainController 中的相关定义:
主控制器
public class MainController implements Initializable
{
// ...
// Variable declared globally:
private static Part currentModPart;
// Functions that use the above variable:
public static Part getModPart()
{
return currentModPart;
}
public static void setModifiedPart(Part modifyPart)
{
MainController.currentModPart = modifyPart;
}
然后我试图将 MainController.getModPart 导入到的类具有以下内容:
修改PartController
// various import statements, including the one below. In the import statement below, IntelliJ highlights
// only the MainController text below in red, and hovering the cursor over it reveals a message,
// "Cannot resolve symbol MainController"'
import static View_Controller.MainController.getModPart;
// Below is the code that involves the getModPart() function that I want to use from MainController
private Part modifiedPart;
public ModifyPartController()
{
modifiedPart = getModPart();
}
所以我不明白为什么 MainController 不能导入。我应该寻找什么来排除一些可能的原因?
解决方案
我的论点是 Jetbrains IDE 无法找到 Controller 的实际类型定义,因为 Stimulus 只是从“@stimulus/core”导出 *,并且 IDE 无法按照间接方式在@stimulus/核心库。
显然对于 IntelliSense 来说并不完美,但你的捆绑器仍然应该可以很好地编译它
推荐阅读
- android - 在片段中单击按钮播放声音 (Kotlin)
- hyperledger-fabric - 排序节点的 TLS 证书轮换 - Cryptogen 到 Fabric CA
- spring-boot - 如何从 maven 依赖项中删除 tomcat 9.0.36。如何授予对关键嵌入式 tomcat 的访问权限
- sql - 查找 id 在前几周可用但在本周不可用
- java - 获取错误 SDK 许可证尚未被接受
- c# - 更新软件如何在代码中工作?是重新下载应用程序还是检查某些文件以查看它们的大小是否不同?
- haskell - 关联类型族和量化约束之间的交互
- microsoft-graph-api - 无效的身份验证令牌。访问令牌验证失败。无效的观众
- perl - Perl Globbing 变量在第一次匹配时停止
- wordpress - 使用响应式设计制作全屏图像滑块的任何解决方案