如何解决Intellij插件:无法初始化组件状态异常
我正在尝试使用Settings->Tools
中的一些配置创建Intellij Idea插件。
我有一个applicationservice
来保存和保存这些配置,但是调用ServiceManager.getService(MyService.class)
时会发生异常,并且该配置在重新打开Intellij Idea时不会持久。
这是异常的堆栈跟踪:
com.intellij.diagnostic.PluginException: Cannot init component state [Plugin: org.mycompany.mycompany-plugin]
at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:116)
at com.intellij.configurationStore.ComponentStoreWithExtraComponents.initComponent(ComponentStoreWithExtraComponents.kt:50)
at com.intellij.serviceContainer.ComponentManagerImpl.initializeComponent$intellij_platform_serviceContainer(ComponentManagerImpl.kt:358)
at com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:58)
at com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:41)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:115)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:69)
at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:411)
at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:394)
at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:20)
at com.mycompany.config.SettingsService.getInstance(SettingsService.java:14)
at com.mycompany.config.SettingsConfigurable.reset(SettingsConfigurable.java:46)
at com.intellij.openapi.options.ex.ConfigurableWrapper.reset(ConfigurableWrapper.java:177)
at com.intellij.openapi.options.ex.ConfigurableCardPanel.reset(ConfigurableCardPanel.java:166)
at com.intellij.openapi.options.ex.ConfigurableCardPanel.lambda$createConfigurableComponent$4(ConfigurableCardPanel.java:118)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)
(a lot more lines here)
Caused by: java.lang.UnsupportedOperationException: configurationSchemaKey must be specified for com.mycompany.config.SettingsService
at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:369)
at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:100)
... 113 more
我没有找到有关“ configurationSchemaKey”的文档,除了它是applicationservice XML参数外,但我找不到应该输入的值。我
这是我定义服务的方式:
<applicationservice
serviceImplementation="com.testmycode.config.SettingsService"
id="com.testmycode.config.SettingsService"/>
我想念什么?
解决方法
configurationSchemaKey
属性是ServiceDescriptor
的一部分,其描述为:
不能指定为{@link State}的一部分,因为要获取注释,必须加载类,但出于性能原因不能这样做。
但是,创建这种用于处理设置的服务并不常见。
请查看您当前的实现,并遵循IntelliJ Platform SDK DevGuide中的Introduction to Settings指南。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。