I'd like to use the spring-boot-starter-web parent for my project. Unfortunately if I try to use it I get the following error message:
[ERROR] [ERROR] Some problems were encountered while processing the POMs: [ERROR] Invalid packaging for parent POM org.springframework.boot:spring-boot-starter-web:2.0.5.RELEASE, must be "pom" but is "jar" @ org.springframework.boot:spring-boot-starter-web:2.0.5.RELEASE @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project com.company:my-artifact:1.0-SNAPSHOT (/home/user/Projects/my-artifact/pom.xml) has 1 error [ERROR] Invalid packaging for parent POM org.springframework.boot:spring-boot-starter-web:2.0.5.RELEASE, must be "pom" but is "jar" @ org.springframework.boot:spring-boot-starter-web:2.0.5.RELEASE
If I change the parent to be spring-boot-starter-parent this error does not happen and the build completes without error.
This is a MWE of my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company</groupId>
<artifactId>my-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>1.2.71</kotlin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The project is a Kotlin project created with IntelliJ by creating a new Maven project from archetype and choosing the kotlin for JVM archetype so the only files I have are pom.xml and the src/main/kotlin/com/company/Hello.kt with the following contents:
package com.company
fun main(args: Array<String>) {
println("Hello, World")
}
And the test file under src/test/kotlin/com/company/HelloTest.kt:
package com.copmany
import org.junit.Test
import kotlin.test.assertEquals
class HelloTest {
}
As far as I can tell my POM is correct. I tried to mvn clean build multiple times but it does not seem to be a problem with the downloaded dependencies. Isn't the spring-boot-starter-web supposed to be used as a parent?
You have to set spring-boot-starter-parent as parent
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
</parent>
and spring-boot-starter-web as your dependency
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With