Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多数据源 #7

Closed
Strivema opened this issue Mar 25, 2020 · 4 comments
Closed

多数据源 #7

Strivema opened this issue Mar 25, 2020 · 4 comments

Comments

@Strivema
Copy link

您好,多数据源配置的AOP读数据库的切点是不是写错了,

@smltq
Copy link
Owner

smltq commented Mar 25, 2020

可以贴上报错信息吗,方便我排查

@Strivema
Copy link
Author

`package com.easy.mybatis.multidatasource.config;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@aspect
@component
public class DataSourceAop {
@pointcut("@annotation(com.easy.mybatis.multidatasource.annotation.Master) " +
"|| execution(* com.easy.mybatis.multidatasource.service...insert(..)) " +
"|| execution(* com.easy.mybatis.multidatasource.service...add(..)) " +
"|| execution(* com.easy.mybatis.multidatasource.service...update(..)) " +
"|| execution(* com.easy.mybatis.multidatasource.service...edit(..)) " +
"|| execution(* com.easy.mybatis.multidatasource.service...delete(..)) " +
"|| execution(* com.easy.mybatis.multidatasource.service...remove(..))")
public void writePointcut() {

}

@Pointcut("!@annotation(com.easy.mybatis.multidatasource.annotation.Master) " +
        "&& (execution(* com.easy.mybatis.multidatasource.service..*.select*(..)) " +
        "|| execution(* com.easy.mybatis.multidatasource.service..*.get*(..)))")
public void readPointcut() {

}`

您看,readPointCut,里面的注解在代码22行,抱歉截屏不了

@smltq
Copy link
Owner

smltq commented Mar 26, 2020

这个没有错的,你注意看下括号,类似这样(!master&&(select||get)。表示没有master注解并且是select或get开头的方法,去读库取数据。

@Strivema
Copy link
Author

抱歉,没看见前面的非,不好意思

@smltq smltq closed this as completed Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants