Access Git DataSource with Java
Last updated: 2025-09-14
The requirement of having Git Data Access is is limited to very few use-cases and not designed to be scalable. Use-cases includes configuration management and data that needs to be versioned and rollbacked, so be sure to know when to use it. |
Pre-Requisite:
-
Create a Git repository
-
Have the repository url, branch, username,and password (or preferably access token) ready.
If you have enabled 2-factor authentication on your Git account, you need to create a Personal Access Token and use it as your password.
Steps:
-
Create Maven project with the following pom.xml:
Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-git-tutorial.adoc - include::inc/git/pom.xml[]
If you are using Eclipse, be sure to refresh your project (select your project→ right click→ Maven→ Update Project) |
-
Create config file at src/main/resources/config.properties with the following contents:
Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-git-tutorial.adoc - include::inc/git/src/main/resources/config.properties[]
-
Create Model with the following contents:
Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-git-tutorial.adoc - include::inc/git/src/main/java/com/app/person/Model.java[]
-
Create DataAccess class with the following contents:
Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-git-tutorial.adoc - include::inc/git/src/main/java/com/app/person/DataAccess.java[]
-
Create Main class with the following contents:
Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-git-tutorial.adoc - include::inc/git/src/main/java/com/app/App.java[]
Thats it, now run your App class.
Full example source-code can be found at https://github.com/smartapi-com/j-framework-data-git |