Spring configuration for embedded H2 database for tests

后端 未结 4 2288
忘了有多久
忘了有多久 2020-12-02 07:04

What does your Spring configuration for integration tests look like using an embedded h2 datasource and, optionally, JUnit?

My first try with a SingleConnectionDataS

4条回答
  •  青春惊慌失措
    2020-12-02 07:52

    I currently include in a test-only springconfig-file as a datasource:

    
        
            
                
                
            
        
    
    
    
    
        
    
    

    Creating / dropping the tables can be done by using executeSqlScript when overriding AbstractAnnotationAwareTransactionalTests.onSetUpBeforeTransaction, or with SimpleJdbcTestUtils.executeSqlScript in an appropriate place.

    Compare also this posting.

提交回复
热议问题