我只是在试验 Quarkus,但我在 ResourceLoader 上遇到了问题。具体来说,当我尝试使用 ResourceLoader 注入时,maven 的全新安装出错了
@Autowired
private ResourceLoader resourceLoader;
这是 Maven 输出:
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.springframework.core.io.ResourceLoader and qualifiers [@Default]
[ERROR] - java member: it.siae.pae.configurations.service.DomainsManager#resourceLoader
[ERROR] - declared on CLASS bean [types=[it.siae.pae.configurations.service.DomainsManager, java.lang.Object], qualifiers=[@Default, @Any], target=it.siae.pae.configurations.service.DomainsManager]
[ERROR] at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:850)
[ERROR] at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:220)
[ERROR] at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:106)
[ERROR] at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:251)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
[ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
[ERROR] at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
[ERROR] at java.lang.Thread.run(Thread.java:748)
[ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.springframework.core.io.ResourceLoader and qualifiers [@Default]
[ERROR] - java member: it.siae.pae.configurations.service.DomainsManager#resourceLoader
[ERROR] - declared on CLASS bean [types=[it.siae.pae.configurations.service.DomainsManager, java.lang.Object], qualifiers=[@Default, @Any], target=it.siae.pae.configurations.service.DomainsManager]
[ERROR] at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:472)
[ERROR] at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:404)
[ERROR] at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:212)
[ERROR] ... 14 more
您知道如何在 Quarkus 中使用 ResourceLoader,或者是否有等效的方法来读取类路径资源中的文件?
这是我目前的情况:
我有项目资源文件夹中的文件,我想阅读它们,例如以这种方式:
使用 Spring Boot 我没有问题。
在此先感谢您的时间!