Я создал проект archetype maven: jersey-quickstart-webapp.Я добавил подготовленные ранее файлы проекта, и мне пришлось добавить в файл pom.xml следующее <dependency>
:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<type>jar</type>
</dependency>
, и теперь полный файл выглядит следующим образом:
<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>org.glassfish.jersey.archetypes</groupId>
<artifactId>ParkingSystem</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>ParkingSystem</name>
<build>
<finalName>ParkingSystem</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
</dependency>
</dependencies>
<properties>
<jersey.version>2.27</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Я знаю, что ошибка означает, что существует более одного корневого элемента.Однако это файл по умолчанию из архетипа, и в качестве корневого элемента <project> </project>
, или, может быть, я чего-то не понимаю?Все остальные элементы находятся внутри элемента <project>
.Единственное изменение, которое я сделал, это то, что я добавил зависимость javax-servlet как первый сверху в теге <dependencies>
.Я проверил xmlns, и ни один из них не является самозакрывающимся.Я нашел тег <project.build.sourceEncoding
в теге <properties>
, но я не думаю, что он влияет на корневой элемент <project> </project>
, так или иначе, он был там по умолчанию.Очевидно, что я что-то упускаю, и я действительно хочу понять.
Это единственное сообщение об ошибке, которое я получил:
[Fatal Error]: 3: 6: разметка в документе следующаякорневой элемент должен быть правильно сформирован.
Нет больше информации.