maven - 找不到HttpSession类

标签 maven grails jetty maven-jetty-plugin

我正在grails 2.3.7上使用groovy构建一个项目。而是使用默认的grails插件,我想将插件配置为maven依赖项。

我还想使用 jetty 服务器代替tomcat服务器和mongodb代替常规的关系数据库。

创建项目后,我执行了“ grails create-pom ”为项目创建pom.xml文件。

我已经对pom.xml添加了以下更改。

  • 删除了对hibernate的依赖,并为mongodb添加了以下依赖
    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>mongodb</artifactId>
        <version>3.0.1</version>
        <scope>compile</scope>
        <type>zip</type>
    </dependency>
    
  • 删除了tomcat的默认插件,并为jetty添加了以下插件。
    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>jetty</artifactId>
        <version>3.0.0</version>
        <scope>compile</scope>
        <type>zip</type>
    </dependency>
    

  • 我还为grails插件配置了存储库。

    在执行代码时,出现以下错误。
    [INFO] Scanning for projects...
    [WARNING] 
    [WARNING] Some problems were encountered while building the effective model for com.mycompany:grails-mongodb-demo:grails-app:0.1
    [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ line 200, column 21
    [WARNING] 
    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
    [WARNING] 
    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
    [WARNING] 
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building grails-mongodb-demo 0.1
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ grails-mongodb-demo ---
    [INFO] Deleting /mnt/data/Work/Tutorials/Practice/grails/grails-mongodb-demo/target
    [INFO] Deleting /mnt/data/Work/Tutorials/Practice/grails/grails-mongodb-demo/plugins (includes = [**/*], excludes = [])
    [INFO] 
    [INFO] --- grails-maven-plugin:2.3.7:clean (default-clean) @ grails-mongodb-demo ---
    [WARNING] Grails Start with out fork
    |Loading Grails 2.3.7
    |Configuring classpath
    |Running pre-compiled script
    .
    |Environment set to development
    ....................
    |Application cleaned.
    [INFO] 
    [INFO] --- grails-maven-plugin:2.3.7:validate (default-validate) @ grails-mongodb-demo ---
    [INFO] 
    [INFO] --- grails-maven-plugin:2.3.7:init (default-init) @ grails-mongodb-demo ---
    [INFO] 
    [INFO] --- grails-maven-plugin:2.3.7:config-directories (default-config-directories) @ grails-mongodb-demo ---
    [INFO] 
    [INFO] --- grails-maven-plugin:2.3.7:maven-compile (default-maven-compile) @ grails-mongodb-demo ---
    [WARNING] Grails Start with out fork
    |Loading Grails 2.3.7
    |Configuring classpath
    |Running pre-compiled script
    ..........
    |Compiling 12 source files
    .Error 
    |
    Fatal error during compilation org.apache.tools.ant.BuildException: java.lang.NoClassDefFoundError: javax/servlet/http/HttpSession (Use --stacktrace to see the full trace)
    

    谁能告诉我,我缺少什么插件,或者我配置不正确吗?

    最佳答案

    将此添加到您pom.xml,看看是否有帮助:-

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
    

    关于maven - 找不到HttpSession类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24723552/

    相关文章:

    java - grails 中的 native CXF 集成

    java - 找不到 :/_ah/start on Google App Engine 的文件

    maven - 高级Docker和Dockerfile的卷/写出理解

    java - Maven HeuristicMixedException 与 Wildfly webapp

    jakarta-ee - 无法加载类 [com.sun.jmx.mbeanserver.RepositorySupport] 以检查 @HandlesTypes

    java - Maven构建错误: Failed to execute goal org. apache.maven.plugins :maven-compiler-plugin:3. 5.1:编译

    mongodb - 在 Grails 和 CloudBees 中使用 MongoDB

    java - chalice 或玩!对于前 RoR 开发人员?

    java - spring boot 1.5.8.RELEASE导入Java 8编译类

    delphi - Indy 10 + SSL = 适用于 Windows 7,不适用于 XP