Starting an H2 Database Server from Maven?

后端 未结 9 1679
不思量自难忘°
不思量自难忘° 2021-01-30 07:09

Suppose I want to create and use an H2 database for my integration tests.

Maven has a command to run tests: mvn test.

Is there a way to tell maven t

9条回答
  •  后悔当初
    2021-01-30 07:47

    In my project, for unit testing, I asked Spring to handle this database creation and initialization. As stated in the H2 documentation, you can create a bean for that:

    
        
    
    

    You simply need to start the Spring context with this configuration when you start your unit tests.

提交回复
热议问题