- Component 把普通的pojo类实例化把普通pojo实例化到spring容器中,相当于配置文件中的
<bean id="" class=""/>
- Bean 就是比如你想使用第三方库的组件,但是在类上不好加Component注解,所以直接在方法上加@Bean,就能注入容器内部了。
- Aspect 一个切面必须的注解,同时需要配合Component注解。
- Slf4j 如果不想每次都写private final Logger logger = LoggerFactory.getLogger(XXX.class); 可以用注解@Slf4j
- Autowired 自动注入类到容器,是通过类型来注入的,若找不到bean便会抛出异常,
如果需要指定,用注解@Qualifier(“userImpl”) - Pointcut 指定切点方法
- Before 在切点方法之前执行
- ConfigurationProperties 从配置文件里读取信息
- Entity Jpa的实体注解
- Id
- DynamicUpdate
- ControllerAdvice 异常捕获的注解
- ExceptionHandler value=xxx.class 这样处理xxx异常,xxx需要extends RuntimeException
- MapperScan 这样就不用在每个Mapper类加@Mapper注解。
yml配置文件
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 123456
url: jdbc:mysql://192.168.43.106:3306/test?characterEncoding=utf-8&useSSL=false
jpa:
show-sql: true
jackson:
default-property-inclusion: non_null
mvc:
view:
prefix: /templates/
suffix: .ftl
redis:
host: 192.168.43.106
port: 6379
server:
context-path: /sell