Exclude servlet-api from test scope Maven

后端 未结 8 955
刺人心
刺人心 2021-02-13 04:43

I have the following dependency in my pom.xml so that my IDE (IntelliJ) has the servlet-api classes available during compilation, but not provided in the build.



        
8条回答
  •  野的像风
    2021-02-13 04:55

    For Gradle users, a setup with Jetty running an embedded webapp based on Spring WebMVC works with the following dependencies:

    apply plugin: 'war'
    apply plugin: 'jetty'
    apply plugin: 'eclipse-wtp'
    dependencies {
    
       // Logging support
       compile 'org.slf4j:slf4j-api:1.7.7'
       runtime 'org.slf4j:slf4j-simple:1.7.7'
    
       // Spring WebMVC part
       compile 'org.springframework:spring-web:4.0.6.RELEASE'
       compile 'org.springframework:spring-webmvc:4.0.6.RELEASE'
       compile 'org.springframework:spring-context:4.0.6.RELEASE'
       compile 'org.springframework:spring-core:4.0.6.RELEASE'
       compile 'org.springframework:spring-beans:4.0.6.RELEASE'
       compile 'org.springframework:spring-expression:4.0.6.RELEASE'
    
       // Jetty support
       compile 'org.eclipse.jetty:jetty-server:8.1.4.v20120524'
       compile 'org.eclipse.jetty:jetty-servlet:8.1.4.v20120524'
       compile 'org.eclipse.jetty:jetty-webapp:8.1.4.v20120524'
       compile 'org.eclipse.jetty:jetty-jsp:8.1.4.v20120524'
    
       // Web Container interaction
       //providedCompile 'javax.servlet:servlet-api:2.5'
       runtime 'jstl:jstl:1.2'
    
       // Unit Testing
       testCompile 'junit:junit:4.11'
       testCompile 'org.mockito:mockito-all:1.9.5'
       testCompile 'org.springframework:spring-test:3.2.0.RELEASE'
    }
    

提交回复
热议问题