按照此处的教程https://jersey.github.io/documentation/latest/getting-started.html
我在父POM文件中添加了存储库引用。然后我运行了这个命令
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false -DgroupId=com.dc.rest -DartifactId=dc-rest -Dpackage=com.dc.rest -DarchetypeVersion=2.22.1
当我打开项目并进入Main
课程时,导入的很多红色标记为Cannot resolve symbol 'glassfish'
提供了错误import org.glassfish.grizzly.http.server.HttpServer
。
我已尝试运行这些命令,但问题仍然存在:
mvn clean install
mvn idea:idea
mvn -U install
干净安装完成且没有错误。
我已经确认我在IntelliJ设置中使用Maven 3.3.3。
我不确定我做错了什么。有什么帮助吗?
自动生成的pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.dc</groupId>
<artifactId>dc</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.dc.rest</groupId>
<artifactId>dc-rest</artifactId>
<version>1.0-SNAPSHOT</version>
<name>dc-rest</name>
<repositories>
<repository>
<id>snapshot-repository.java.net</id>
<name>Java.net Snapshot Repository for Maven</name>
<url>https://maven.java.net/content/repositories/snapshots/</url>
<layout>default</layout>
</repository>
</repositories>
<properties>
<jersey.version>2.22.1</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<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>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.dc.rest.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
版本
D:\git\dc>mvn --version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T05:57:37-06:00)
Maven home: C:\Program Files\apache-maven-3.3.3\bin\..
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: C:\Progra~1\Java\jdk1.8.0_60\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows server 2008 r2", version: "6.1", arch: "amd64", family: "dos"
D:\git\dc>java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)