Java - Springboot
2021-02-16 09:20
标签:record 注解 get config ali vat data ble 统一 @SpringBootApplication:@Configuration + @EnableAutoConfiguration + @ComponentScan @Controller:类注解,控制器层,类中方法配合@RequestMapping @Repository:确保DAO或者repositories提供异常转译 @Qualifier:@Qualifier(“name”) + @Autowired 全局异常处理 其他注解 Java - Springboot 标签:record 注解 get config ali vat data ble 统一 原文地址:https://www.cnblogs.com/wjcx-sqh/p/12708253.html注解
@SpringBootApplication
public class AfvappApplication {
public static void main(String[] args) {
SpringApplication.run(AfvappApplication.class, args);
}
}
@RestController:类注解,控制器层,REST风格,@Controller + @ResponseBody@RestController
@RequestMapping("/demo")
public class DemoController {
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String hello() { ... }
}
@Repository
public interface SqlserverMapper {
List
@Resource:@Autowired
@Qualifier(value = "sqlserverDataSource")
private DataSource sqlserverDataSource;
@Resource(name = "yt_MATHandleServiceImpl")
private MATHandleService ytService;
@Resource(name = "cw_MATHandleServiceImpl")
private MATHandleService cwService;
@ControllerAdvice:包含@Component,可以被扫描到,统一处理异常
@ExceptionHandler(Exception.class):方法注解,表示遇到该异常就执行以下方法@Service:类注解,服务层
@Component:泛指组件
上一篇:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
下一篇:C++——数组与指针