How to java-configure separate datasources for spring batch data and business data? Should I even do it?

后端 未结 7 1575
感情败类
感情败类 2020-11-29 22:33

My main job does only read operations and the other one does some writing but on MyISAM engine which ignores transactions, so I wouldn\'t require necessarily tr

7条回答
  •  一个人的身影
    2020-11-29 23:16

    Assuming you have 2 data sources, one for spring batch metadata such as job details[lets say CONFIGDB] and other for your business data [lets say AppDB]:

    Inject CONFIGDB into jobRepository, like this:

     
        
        
        
        
      
    

    Now you can inject the AppDB dartasource into your DAO's OR Writers if any like..

       
              
       
    

    OR

    you can do define a resource and Inject this AppDB with jndi lookup in the class where its needed like:

    public class ExampleDAO {
    
    @Resource(lookup = "java:comp/env/jdbc/AppDB")
    DataSource ds;
    

    }

提交回复
热议问题