The post How to convert JSON schema to Java classes using maven plugin appeared first on Little Big Extra.
]]>We often need to convert JSON schema’s to Java classes, there is a jsonschema2pojo-maven-plugin which helps in generating POJO(plain old java objects) from JSON or JSON schema.
To use it all we need is add this plugin, update dependencies and run mvn generate
Add this plugin to your POM.XML under plugin section
<plugin> <groupId>org.jsonschema2pojo</groupId> <artifactId>jsonschema2pojo-maven-plugin</artifactId> <version>0.4.34</version> <configuration> <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory> <targetPackage>com.test.gen</targetPackage> <useCommonsLang3>true</useCommonsLang3> </configuration> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin>
The generated types depend on Commons Lang library for equals, hashCode and toString. Also, you need to add Jackson-databind which contains the data-binding functionality and tree-model for Jackson Data Processor, this jar has a transitive dependency on jackson-core and jackson-annotations so they will be downloaded automatically.
<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency>
You can run
mvn generate-sourcesgoal to generate the java classes. All files will be added in the target/java-gen folder by default
${basedir}/src/main/gen
Make sure that generated folder is added as a source folder in your IDE (Properties ->Java build Path -> Add source folder in eclipse).
If you want to generate Java classes from JSON rather than JSON schema add
<sourceType>json</sourceType>
inside the configuration tag as default source type is JSON Schema.
The post How to convert JSON schema to Java classes using maven plugin appeared first on Little Big Extra.
]]>The post Using Jenkins to Build and Deploy Docker images appeared first on Little Big Extra.
]]>Jenkins is one of the most popular continuous integration tools and is widely used. It can be used to create pipelines, run jobs and do automated deployments.
There are many plugins available which can be added to Jenkins and makes it really powerful.
Recently I wanted to do an automated deployment of Docker Images to docker server and tried using docker-plugin but after spending some time it looked to me that if it asking for too much of information and for each operation you need to provide arguments, I would prefer a solution which is more dynamic and picks things automatically with user providing the bare essentials parameters arguments.
This is how it looks like
In a nutshell, all I wanted was
Once all 3 steps have been tested and completed all is left to be done in Jenkins is to Invoke the clean install goal as shown below.
If you want to push the docker image to some repository after building, testing and deploying.Please follow this link
The post Using Jenkins to Build and Deploy Docker images appeared first on Little Big Extra.
]]>The post How to Enable Docker Remote REST API on Docker Host appeared first on Little Big Extra.
]]>
Docker provides remote REST API which is beneficial if you want to connect to a remote docker host. Few of the functions which you can achieve using Docker REST API over a simple browser are
In this tutorial, I will show you
Over the internet, most of the people have suggested editing DOCKER_OPTS variable.
/etc/default/dockerfile but it didn’t have any effect
/etc/init/docker.confbut again no success.
vi /lib/systemd/system/docker.service
ExecStart=/usr/bin/docker daemon -H=fd:// -H=tcp://0.0.0.0:2375
systemctl daemon-reload
sudo service docker restart
curl http://localhost:2375/images/json
The post How to Enable Docker Remote REST API on Docker Host appeared first on Little Big Extra.
]]>The post How To Push Docker Images To Docker Hub Repository Using Docker Maven plugin appeared first on Little Big Extra.
]]>
If you want to push a docker image to Docker Hub repository, it can be achieved using docker maven plugin from fabric8.io. This plugin lets you build images, start and stop containers and push it to Docker repositories
&nsbp;
<plugin> <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.20.0</version>....
<name>springboot-mongo-dockerimage:${project.version}</name> <alias>springboot-mongo-dockerimage</alias> <build> <dockerFileDir>${project.basedir}</dockerFileDir> </build>
<registry>registry.hub.docker.com/YOUR_DOCKER_HUB_USERNAME</registry>
<authConfig> <username>ENTER YOUR DOCKER HUB USERNAME LIKE abhishek</username> <password>ENTER YOUR DOCKER HUB PASSWORD</password> </authConfig>
<execution> <id>push</id> <phase>post-integration-test</phase> <goals> <goal>push</goal> </goals> </execution>
Here is the complete build section from the plugin, hope this help.
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.20.0</version> <configuration> <registry>registry.hub.docker.com/YOUR_DOCKER_HUB_USERNAME</registry> <images> <image> <name>springboot-mongo-dockerhub:${project.version}</name> <alias>springboot-mongo-dockerhub</alias> <build> <dockerFileDir>${project.basedir}</dockerFileDir> </build> <run> <namingStrategy>alias</namingStrategy> <dependsOn> <container>mongo</container> </dependsOn> <links> <link>mongo</link> </links> <ports> <port>9876:8080</port> </ports> <log> <prefix>TC</prefix> <date>default</date> <color>cyan</color> </log> </run> </image> </images> <authConfig> <username>ENTER YOUR DOCKER HUB USERNAME LIKE abhishek</username> <password>ENTER YOUR DOCKER HUB PASSWORD</password> </authConfig> </configuration> <executions> <execution> <id>start</id> <phase>pre-integration-test</phase> <goals> <goal>stop</goal> <goal>build</goal> <goal>start</goal> </goals> </execution> <execution> <id>push</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> <goal>push</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
If you get an error : io.fabric8:docker-maven-plugin:0.20.0:build failed: A tar file cannot include itself
The post How To Push Docker Images To Docker Hub Repository Using Docker Maven plugin appeared first on Little Big Extra.
]]>The post How to enable jenkins to auto build with BitBucket server appeared first on Little Big Extra.
]]>One of the goals of Continuous Integration andContinuous deployment is that once the code is pushed to the repository it should be tested, built and then packaged for deployment. BitBucket webhook makes is possible to trigger real-time notifications to Jenkins server so the auto build starts as soon as the code is pushed.
In this tutorial, we will
Once you have installed BitBucket server on your machine, make sure that it is working. The default port is 7990, so you should be able to access it by using localhost: 7990.
The post How to enable jenkins to auto build with BitBucket server appeared first on Little Big Extra.
]]>The post How to Install Jenkins on Docker appeared first on Little Big Extra.
]]>Jenkins is a great tool to build and package artifacts, it can be either deployed independently as a service in docker, lets go through the steps required to install Jenkins on docker as a container.
In this tutorial, we will
docker pull Jenkins
docker volume create --name jenkins_data docker run --name jenkins -d -v jenkins_data:/var/jenkins_home -p 8080:8080 -p 50000:50000 jenkins:latest
OR
docker run --name jenkins -d -v /Users/jenkins:/var/jenkins_home -p 8080:8080 -p 50000:50000 jenkins:latest
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 041465f0254e jenkins:latest "/bin/tini -- /usr..." 43 hours ago Up 58 seconds 0.0.0.0:50000>50000/tcp, 0.0.0.0:8082->8080/tcp jenkins
The post How to Install Jenkins on Docker appeared first on Little Big Extra.
]]>The post How to Install Artifactory on Docker appeared first on Little Big Extra.
]]>JFrog Artifactory is a repository manager used for versioning deployable like a jar, war, docker image etc. Artifactory Pro is a licensed/paid version which will let you create repositories for docker images and much more.Artifactory OSS is open source and a restrective version where you can create maven repositories and few others.
In this tutorial, we will
Pull the Artifactory OSS Docker Image, it’s an open source image. For this tutorial, we will go ahead with Artifactory OSS
docker pull docker.bintray.io/jfrog/artifactory-oss:latest
docker run --name artifactory -d -p 8081:8081 docker.bintray.io/jfrog/artifactory-pro:latest
It is important to persist the artifacts which will be fed to Artifactory, so we have two options here
If artifactory was running using above command already then you need to stop the container using
docker stop artifactory docker rm artifactory
docker volume create --name artifactory5_data docker run --name artifactory-5.0.0 -d -v artifactory5_data:/var/opt/jfrog/artifactory -p 8081:8081 docker.bintray.io/jfrog/artifactory-pro:latest
OR
docker run --name artifactory-5.0.0 -d -v /Users/abhishek/jfrog/artifactory:/var/opt/jfrog/artifactory -p 8081:8081 docker.bintray.io/jfrog/artifactory-oss:latest
http://SERVER_DOMAIN:8081/artifactory
The post How to Install Artifactory on Docker appeared first on Little Big Extra.
]]>The post How to add remote archetype catalog in Eclipse appeared first on Little Big Extra.
]]>Maven remote catalogues are very useful in starting a project quickly and neatly. The project structure including src, test directory are created along with pom dependencies.
Follow below steps to add remote archetype catalogue
If you are behind a proxy you might need to go to Windows -> Preference-> Network and add the proxy details
Follow this Video for more details
The post How to add remote archetype catalog in Eclipse appeared first on Little Big Extra.
]]>