简体   繁体   中英

How to Create a Jar file in Spring boot with Data Source that is not live?

I've configured properties file with data source ie URL of a database, and credentials of some other System since I need to build executable jar and and deploy the application into that System and it is not accessible.

Since the URL is different it's not remotely accessible, when I try to build, exception is occurring since it's looking for configuring live database which is not existed.

So, I want to build and create executable jar file. But data source isn't live in my system. But It's going to be once I deploy the jar into another system.

How can I achieve this?

You can create two properties, application-development.properties , for development configuration, and application-production.properties , for live configuration.

To create a jar, use mvn clean install .

After that go to the target folder and use below command to run the jar file

java -jar -Dspring.profiles.active= production YourJarFileName.jar  // if you want to run live database

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM