Maven 和 graphql-java

Posted

技术标签:

【中文标题】Maven 和 graphql-java【英文标题】:Maven and graphql-java 【发布时间】:2017-12-31 22:43:38 【问题描述】:

我正在尝试从 http://graphql-java.readthedocs.io/en/stable/getting_started.html#hello-world 运行 HelloWorld 示例

我有编译问题:

Information:java: Errors occurred while compiling module 'graphqlApp'
Information:javac 1.8.0_131 was used to compile java sources
Information:25.07.17 22:41 - Compilation completed with 17 errors and 3 warnings in 1s 873ms
Warning:java: source value 1.5 is obsolete and will be removed in a future release
Warning:java: target value 1.5 is obsolete and will be removed in a future release
Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.
/home/marcin/graphqlApp/src/main/java/HelloWorld.java
Error:(1, 15) java: package graphql does not exist
Error:(2, 22) java: package graphql.schema does not exist
Error:(3, 22) java: package graphql.schema does not exist
Error:(7, 22) java: package graphql does not exist
Error:(7, 1) java: static import only from classes and interfaces
Error:(8, 29) java: package graphql.schema does not exist
Error:(8, 1) java: static import only from classes and interfaces
Error:(9, 29) java: package graphql.schema does not exist
Error:(9, 1) java: static import only from classes and interfaces
Error:(14, 9) java: cannot find symbol
  symbol:   class GraphQLObjectType
  location: class HelloWorld
Error:(17, 31) java: cannot find symbol
  symbol:   variable GraphQLString
  location: class HelloWorld
Error:(16, 24) java: cannot find symbol
  symbol:   method newFieldDefinition()
  location: class HelloWorld
Error:(14, 39) java: cannot find symbol
  symbol:   method newObject()
  location: class HelloWorld
Error:(22, 9) java: cannot find symbol
  symbol:   class GraphQLSchema
  location: class HelloWorld
Error:(22, 32) java: cannot find symbol
  symbol:   variable GraphQLSchema
  location: class HelloWorld
Error:(26, 9) java: cannot find symbol
  symbol:   class GraphQL
  location: class HelloWorld
Error:(26, 27) java: cannot find symbol
  symbol:   variable GraphQL
  location: class HelloWorld

我的 Maven 文件:

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>graphqlApplication</groupId>
    <artifactId>graphqlApplication</artifactId>
    <version>1.0-SNAPSHOT</version>

    <repositories>
        <repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>bintray-andimarek-graphql-java</id>
            <name>bintray</name>
            <url>http://dl.bintray.com/andimarek/graphql-java</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.graphql-java</groupId>
            <artifactId>graphql-java</artifactId>
            <version>3.0.0</version>
        </dependency>
    </dependencies>
</project>

我的 Maven 配置有什么问题?

【问题讨论】:

【参考方案1】:

要使用 bintray 存储库中的最新版本,请更改依赖项版本。你可以找到发布here。

<dependencies>
    <dependency>
        <groupId>com.graphql-java</groupId>
        <artifactId>graphql-java</artifactId>
        <version>2019-04-09T05-29-53-bd9240c</version>
    </dependency>
</dependencies>

如果你想使用最新的稳定版本(11.0.0)删除不必要的存储库声明并使用它。

<!-- https://mvnrepository.com/artifact/com.graphql-java/graphql-java -->
<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-java</artifactId>
    <version>11.0.0</version>
</dependency>

【讨论】:

谢谢。我还必须单击我的 IntelliJ 以允许 Maven 解析依赖项。

以上是关于Maven 和 graphql-java的主要内容,如果未能解决你的问题,请参考以下文章

maven和ant的区别

ant与maven的区别

2.Maven实战 --- maven的安装和配置

maven安装和创建maven工程

(转)MAVEN的安装和Myeclipse+maven的配置和使用

Maven的安装Maven仓库和Maven工程目录