2015-10-12 95 views
8

根據我的項目提供org.glassfish.json.JsonProviderImpl沒有找到 我不明白爲什麼它抱怨GlassFish的,因爲我使用另一個庫JSON:提供org.glassfish.json.JsonProviderImpl沒有找到

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://maven.apache.org/POM/4.0.0" 
    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>magistics</groupId> 
    <artifactId>magistics</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>war</packaging> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.tomcat.maven</groupId> 
       <artifactId>tomcat7-maven-plugin</artifactId> 
       <version>2.2</version> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencies> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>javax.servlet-api</artifactId> 
      <version>3.0.1</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.websocket</groupId> 
      <artifactId>javax.websocket-api</artifactId> 
      <version>1.1</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.json</groupId> 
      <artifactId>javax.json-api</artifactId> 
      <version>1.0</version> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.36</version> 
     </dependency> 
    </dependencies> 
</project> 

enter image description here

我如何可以用我的JSON庫,並避免使用GlassFish的任何想法?

回答

12

問題是javax.json-api只包含API(接口)並且沒有實現。

如果您的服務器配備了預先捆綁實現這應該工作,但如果沒有,你可以添加以下的依賴得到實現:

<dependency> 
    <groupId>org.glassfish</groupId> 
    <artifactId>javax.json</artifactId> 
    <version>1.0.4</version> 
</dependency> 
相關問題