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 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 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.
]]>