简体   繁体   中英

Can't configure gradle on Jax-RS project in IntelliJ

I experiencing issues regarding my Gradle setup for my Jax-RS project in an IntelliJ idea

javax.servlet.ServletException: A MultiException has 2 

exceptions.  They are:
1. java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
2. java.lang.IllegalStateException: Unable to perform operation: create on com.mkl.rest.LionResource

here is my dummy code that I tested on

@Path("lion")
public class LionResource
{

private BaseRest<AnyObject, AnyObjectDTO> baseRest        = new BaseRest<AnyObject, AnyObjectDTO>(AnyObject.class, new AnyObjectDTO());
private AnyObjectFacade anyObjectFacade = new AnyObjectFacade(JPAConnection.getEntityManagerFactory());

@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getAnyObjects()
{
    return baseRest.get();
}

build.gradle

  group 'com.mkl'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'war'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

    dependencies {
        compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
        compile group: 'javax', name: 'javaee-api', version: '8.0'
        compile group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.0.1'
        compile group: 'org.glassfish.jersey.core', name: 'jersey-server', version: '2.26'
        compile group: 'org.glassfish.jersey', name: 'jersey-bom', version: '2.26'
        compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet-core', version: '2.26'
        compile group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.26'
        compile group: 'org.hibernate', name: 'hibernate-core', version: '5.3.6.Final'
        compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.47'

        testCompile group: 'junit', name: 'junit', version: '4.12'
    }

I have tried looking for solutions, and for the first exception I found that I should add some dependencies to my pom.xml

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9

however, since I'm using Gradle and can't add those files since I don't have a pom.xml

regarding my second exception, I'm not sure what 'create' refers to?

将此添加到您的build.gradle

compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM