Require a sample pom.xml for a Java spring boot webservices with plugin for maven and docker

0 votes

Could you please provide a sample pom.xml for a Java spring boot webservices which should have the plugin for Maven and Docker, which I can use in Openshift to create a base image.

Dec 20, 2018 in Docker by Ali
• 10,290 points
58 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hey @Ali, have a look at this sample code

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
  </parent>
  <groupId>com.demo.kubernetes.springcloud</groupId>
  <artifactId>web</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <properties>
    <start-class>com.demo.kubernetes.springcloud.web.WebServer</start-class>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>Finchley.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <!-- Setup Spring Boot -->
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
   </dependency>
    <dependency>
      <!-- Setup Spring MVC & REST, use Embedded Tomcat -->
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <!-- Setup Spring Data common components -->
      <groupId>org.springframework.data</groupId>
      <artifactId>spring-data-commons</artifactId>
    </dependency>
    <dependency>
      <!-- Testing starter -->
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <dependency>
      <!-- Spring Cloud starter -->
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter</artifactId>
    </dependency>
    <!-- Gson: Java to Json conversion -->
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.8.5</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.spotify</groupId>
        <artifactId>dockerfile-maven-plugin</artifactId>
        <version>1.3.6</version>
        <configuration>
          <tag>web-service</tag>
         <repository>konuratdocker/spark-examples</repository>
          <imageTags>
            <imageTag>web-service</imageTag>
          </imageTags>
          <buildArgs>
            <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
          </buildArgs>
        </configuration>
     </plugin>
   </plugins>
  </build>
</project>

Hope it helps :)

answered Dec 20, 2018 by Eric

Related Questions In Docker

+1 vote
1 answer

How to deploy a java app to Docker?

If you are having JAR file, the quickest ...READ MORE

answered Aug 2, 2018 in Docker by Damon Salvatore
• 5,250 points
24 views
0 votes
1 answer

How to base a docker volume with docker container?

Run the following command: docker run -d --volumes-from ...READ MORE

answered Aug 5, 2018 in Docker by Sophie may
• 9,050 points
50 views
0 votes
1 answer

Persisting data in a docker swarm with glusterfs

You will have to create a volume ...READ MORE

answered Aug 24, 2018 in Docker by Nilesh
• 6,900 points
401 views
0 votes
1 answer

How to save a Dynamic port in Docker for Windows?

The mapped ports can be accessed via ...READ MORE

answered Sep 4, 2018 in Docker by Tyrion anex
• 8,280 points
28 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,100 points
56 views
0 votes
1 answer

What is the difference between a Docker image and a container?

Here is very basic explanation for image ...READ MORE

answered Sep 4, 2018 in Docker by Damon Salvatore
• 5,250 points
197 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.