无法自定义春季启动库项目到我的应用程序

发布于 2025-02-12 07:29:47 字数 1224 浏览 2 评论 0原文

将自定义的弹簧启动库jar导入我的应用程序,并且在我运行应用程序时显示以下错误。

Parameter 0 of constructor in com.dilla.de.orca.addresssvc.service.TestScheduler required a bean of type 'com.dilla.de.orca.flowersvc.service.FlowerServiceImpl' that could not be found.

库模块具有以下包装

  • 配置
    • flowerserviceConfiguration-为jaxb2marshaller创建豆类,网络维修板, WebServiceMessagesender
  • 模型
  • 服务
    • flowerservice(接口无注释)
    • flowerserviceimp实现界面并调用floweradapter
    • FlowerAdapter(呼叫外部网站服务)
  • SRC/MAIN/ROSISY
    • application.properties定义外部网络服务URL和相关属性
FlowerSvcLibApplication.java
    public static void main(final String[] args) {
        SpringApplication.run(FlowerSvcLibApplication.class, args);
    }

我在我的应用程序测试功能的应用程序中自动自动化花卉服务界面 图书馆罐子

@Component
public class MyFlowerService {

    private  FlowerService service;
    @Autowired
    public MyFlowerService(final FlowerService service) {
        this.service = service;
    }

我收到了之前发布的错误。我确实做了更多的研究,一个建议是创建“自己的自动配置”,但我仍然不明白。如何创建自动配置类来处理我的库类,以及使用我的库的客户端如何提供应用程序属性值。当前,我硬编码实际值,例如网络服务URL,现在客户端可以将其更改为测试或产品,并且要做我的库模块设置应该如何?

Importing custom spring-boot library jar to my application, and autowiring show the following error when I run the application

Parameter 0 of constructor in com.dilla.de.orca.addresssvc.service.TestScheduler required a bean of type 'com.dilla.de.orca.flowersvc.service.FlowerServiceImpl' that could not be found.

The Library module has following packages

  • Configuration
    • FlowerServiceConfiguration - create beans for Jaxb2Marshaller, WebServiceTemplate,
      webserviceMessageSender
  • Model
  • Service
    • FlowerService (an interface no annotation)
    • FlowerServiceImp implements the interface and calls FlowerAdapter
    • FlowerAdapter (call external webservice)
  • Src/main/resources
    • Application.properties define external webservice url, and related properties
FlowerSvcLibApplication.java
    public static void main(final String[] args) {
        SpringApplication.run(FlowerSvcLibApplication.class, args);
    }

I was autowiring the Flower Service interface as follows, in my application to test functionality
of library jar

@Component
public class MyFlowerService {

    private  FlowerService service;
    @Autowired
    public MyFlowerService(final FlowerService service) {
        this.service = service;
    }

I got the error I posted earlier. I did do more research, and one suggestion was creating “own auto-configuration”, but I still did not understand. How do I create autoConfiguration class to handle to autowire my library class, and also how does client using my library provide application property values. Currently, I hard coded actual values for example a webservice url, and now client can change this to be test or prod, and to do that how does my library module setup should be?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情魔剑神 2025-02-19 07:29:47

请检查@componenetscan&确保它具有类似“ com.dilla.de.orca”的包装路径

Please check @ComponenetScan & make sure that it has package path something like this “com.dilla.de.orca”

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文