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 21, 2018 in Docker by Ali
• 11,360 points
1,101 views

1 answer to this question.

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 21, 2018 by Eric

Related Questions In Docker

0 votes
1 answer

What is the process for stopping and restarting a docker container?

If you want to stop a docker ...READ MORE

answered Jul 3, 2019 in Docker by Sirajul
• 59,230 points
9,342 views
0 votes
0 answers

How to invoke a Docker secret key in c# console application? I want a sample code for it.

Actually I want hide a salt key ...READ MORE

Mar 20, 2020 in Docker by anonymous
• 120 points
1,146 views
+2 votes
1 answer
+2 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
• 58,020 points
2,720 views
0 votes
3 answers

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

Images are read-only templates that contain a ...READ MORE

answered Aug 10, 2020 in Docker by Vishal
• 260 points
6,676 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP