1

I'm trying to do mvn clean install and the package to creates a war file to be deployed on Tomcat server but the thing is these jars below are getting created even after deleting the related dependency (...\WEB-INF\lib ) file :

spring-security-oauth2-client-5.1.0.RELEASE.jar

spring-security-oauth2-client-5.2.1.RELEASE.jar

And I only need to use one on them , please check below POM file:

 <modelVersion>4.0.0</modelVersion>

    <groupId>com.baeldung.keycloak</groupId>
    <artifactId>E-Services-Portal</artifactId>
    <packaging>war</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.keycloak.bom</groupId>
                <artifactId>keycloak-adapter-bom</artifactId>
                <version>3.3.0.Final</version>
                <type>pom</type>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-security</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-oauth2-client</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.junit.vintage</groupId>
                        <artifactId>junit-vintage-engine</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-jasper</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.glassfish.web</groupId>
                <artifactId>el-impl</artifactId>
                <version>2.2</version>
            </dependency>
            <dependency>
                <groupId>org.axonframework</groupId>
                <artifactId>axon-spring-boot-starter</artifactId>
                <version>3.4</version>
            </dependency>
        </dependencies>


    <repositories>
        <repository>
            <id>central</id>
            <name>Maven Plugin Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
        </repository>

    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <webappDirectory>/sample/servlet/container/deploy/directory</webappDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>

I tired to remove spring-boot-starter-security dependency and deployed it didn't work out still getting the same problem and i tried to remove spring-boot-starter-oauth2-client still getting the same.

And I realize when I add ( spring-boot-starter-oauth2-client ) dependency it will added these 2 jars in External Lib folder

Duaa
  • 77
  • 3
  • 10

1 Answers1

0

When creating a WAR is best to mvn clean package as the WAR doesnt need to go into your local Maven repository

If you use spring-boot-maven-plugin Maven will (during the package phase) create a SpringBoot executable JAR file (JAR with all dependencies), you also use the maven-war-plugin which creates the WAR file. I dont think you need both.

Beppe C
  • 11,256
  • 2
  • 19
  • 41