How to embed H2 database into jar file delivered to the client?

前端 未结 4 977
无人及你
无人及你 2021-01-13 02:41

I use H2 database for a desktop application in embedded mode. When I compress the application into jar file the database file is omitted. So, when I run MyApplication.jar no

4条回答
  •  感动是毒
    2021-01-13 03:17

    If you are using Maven to build your project, just use maven-shade-plugin... great results and control, I've been using it a lot.

    For embedding all your dependencies you would write something like:

      
        org.apache.maven.plugins
        maven-shade-plugin
        1.4
        
          
            package
            
              shade
            
          
        
      
    

    Then with just a normal "mvn package" you'll have all your dependencies' jars included in your application jar.

    With further configuration you can control what gets included and what not.

提交回复
热议问题