习惯了spring注解风格,方便好用,现在用vert.x框架,怎么使用spring注解呢?

2.maven安装依赖包

<!--spring注解依赖包-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>5.1.5.RELEASE</version>
    </dependency>

3.注册bean有两个方法:xml注册,注解注册

方法1:xml注册

新建一个xml配置文件

vert.x框架-使用spring注解功能

 

 

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
    <!--    默认单例,,加上scope="prototype"为多例-->
        <bean name="eatService" class="xue.myVertX.service.serviceImpl.EatServiceImpl" scope="prototype"/>


</beans>
spring-context.xml

相关文章:

  • 2022-12-23
  • 2022-01-05
  • 2021-12-06
  • 2022-01-04
  • 2021-08-09
  • 2021-05-19
  • 2021-12-14
  • 2021-08-15
猜你喜欢
  • 2021-06-10
  • 2022-12-23
  • 2021-09-26
  • 2022-12-23
  • 2021-06-23
  • 2022-12-23
  • 2021-12-05
相关资源
相似解决方案