How to launch local DynamoDB programmatically?

后端 未结 2 601
清歌不尽
清歌不尽 2021-02-05 13:08

I am able to launch a local DynamoDB server from bash through this command:

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedD         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 13:48

    Write a gradle task to extract the Dynamodb-Local zip and now you can use https://github.com/marcoVermeulen/gradle-spawn-plugin gradle plugin to launch the dynamodb local. It is very easy to use and no need to do any process builder magic.

    Sample code -

    // to start dynamodb-local
    task launch(type: SpawnProcessTask) {
        println("Launching....")
        command "java -Djava.library.path=/location/to/dynamodb-local/DynamoDBLocal_lib -jar /location/to/dynamodb-local/DynamoDBLocal.jar -inMemory -delayTransientStatuses"
        ready "Initializing DynamoDB Local"
    }
    
    // to stop dynamodb-local process
    task stop(type: KillProcessTask)
    

提交回复
热议问题