找不到HttpSession类

时间:2014-07-13 14:11:00

标签: maven grails jetty maven-jetty-plugin

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

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

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

我在pom.xml中添加了以下更改。

  1. 删除了hibernate的依赖项,并为mongodb添加了以下依赖项

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

    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>jetty</artifactId>
        <version>3.0.0</version>
        <scope>compile</scope>
        <type>zip</type>
    </dependency>
    
  3. 我还为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)
    

    任何人都可以告诉我,我缺少什么插件,或者我有一些错误的配置。

1 个答案:

答案 0 :(得分:1)

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

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