vscode-spring-initializr icon indicating copy to clipboard operation
vscode-spring-initializr copied to clipboard

Using Add Starters will repeatedly add dependencies

Open LuckySgr opened this issue 1 year ago • 1 comments

This is the result(On the left is the one before add,On the right is after add)

PS: Every time add starters are used, dependencies will be added

image

LuckySgr avatar Jul 06 '24 03:07 LuckySgr

same here image image after adding spring data jpa and posgresql driver image

oubrikyoussef avatar Aug 07 '24 12:08 oubrikyoussef

I have the same issue when trying to add new dependencies whether I create the project using Spring Initalizr inside VS Code or import an existing project.

KajP avatar Oct 28 '24 11:10 KajP

Do you mind pasting the entire POM of the original project to which starters are being added please? I'm trying to reproduce it but with no luck so far... Perhaps there is something in the XML that prevents from finding the existing <dependencies> element

BoykoAlex avatar Nov 25 '24 21:11 BoykoAlex

Thank you for your response Below is the complete pom.xml file for the original project:

<?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 https://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>3.3.1</version>
		<relativePath />
		<!-- lookup parent from repository -->
	</parent>
	<groupId>com.openclassrooms</groupId>
	<artifactId>watchlist</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>watchlist</name>
	<description>Demo project for Spring Boot</description>
	<url />
	<licenses>
		<license />
	</licenses>
	<developers>
		<developer />
	</developers>
	<scm>
		<connection />
		<developerConnection />
		<tag />
		<url />
	</scm>
	<properties>
		<java.version>22</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.13.2</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-validation</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>
</project>

I also attempted to add a new dependency, but instead of appending to the existing <dependencies> block, a new <dependencies> tag was created, and the chosen dependency was added within it.

Screenshot of the new dependencies tag

Screenshot showing the added dependency

Let me know if you need more details or have any thoughts on resolving this behavior.

oubrikyoussef avatar Nov 25 '24 22:11 oubrikyoussef

It is likely due to tags like this: <developer /> if these are replaced with <developer></developer> then it might start working...

Namely it is the <url /> under the <project> tag (under the root)

BoykoAlex avatar Nov 25 '24 22:11 BoykoAlex

Thank you for your guidance! I replaced the self-closing tags, including under the tag, with opening and closing tags , and it resolved the issue. I appreciate your help

oubrikyoussef avatar Nov 26 '24 21:11 oubrikyoussef