MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    套用插件的Mirai框架里如何使用Mybatis和Spring呀?

    开发交流
    6
    6
    538
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • X
      XinLinYu last edited by

      我在Impl里引用了Mapper,并加上了@Autowired,但是调用的时候还是报了空指针,这里我想的是,可能是扫包的问题,但是Spring配置扫包的@MapperScan加在extends JavaPlugin 的主类上面也没用呀……
      所以就想问下Mirai框架可以配合使用Mybatis和Spring甚至是Springboot吗?

      1 Reply Last reply Reply Quote 0
      • ryoii
        ryoii 梦中的鸡翅 last edited by

        我猜你用的是SpringBoot, 如果单纯使用spring容器,在插件初始化的地方定义自己的bean就好了。springboot作为侵入的开发框架,不适合作插件开发

        1 Reply Last reply Reply Quote 1
        • Karlatemp
          Karlatemp last edited by

          springboot作为侵入的开发框架,不适合作插件开发

          1 Reply Last reply Reply Quote 1
          • RainChan
            RainChan 摸鱼 last edited by

            你也可以直接将mirai作为依赖库使用,这样就可以将它配合Spring生态了

            1 Reply Last reply Reply Quote 1
            • cssxsh
              cssxsh last edited by

              如果只是想使用Mybatis配置数据库的话,并不一定需要spring框架

              1 Reply Last reply Reply Quote 0
              • H
                hundun000 ⭐2021⭐ last edited by hundun000

                为什么我的插件放入mcl启动,代码执行new ClassPathXmlApplicationContext("spring.xml"),会报错找不到文件?

                buildPlugin得到的jar的结构如下,"spring.xml"在根目录。

                b32bf6cf-23df-44e5-8c43-184af21014b1-image.png

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact