我在IntelliJ 搭建jfinal + maven环境,依赖如下:
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>javax.servlet.jsp.jstl-api</artifactId> <version>1.2.1</version> </dependency> <dependency> <groupId>org.eclipse.jetty.orbit</groupId> <artifactId>org.apache.taglibs.standard.glassfish</artifactId> <version>1.2.0.v201112081803</version> </dependency> <dependency> <groupId>com.jfinal</groupId> <artifactId>jfinal</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>com.jfinal</groupId> <artifactId>jetty-server</artifactId> <version>8.1.8</version> <!--<scope>provided</scope>--> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.3.10.v20160621</version> <configuration> <httpConnector> <port>8080</port> </httpConnector> <stopPort>9966</stopPort> <stopKey>stop</stopKey> <scanIntervalSeconds>5</scanIntervalSeconds> <webApp> <contextPath>/</contextPath> </webApp> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.4</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build>
package com.ef.demo.common; import com.jfinal.core.JFinal; public class Stratup { public static void main(String[] args) { JFinal.start("src/main/webapp", 8080, "/", 5); } }
public class IndexController extends Controller { public void index(){ // renderText("hello JFinal world!");//正常 renderJsp("index.jsp");//报错: JSP support not configured } }
以上配置启动正常但是访问jsp页面会报错:
JSP support not configured我有2个问题:
1. 如何配置在开发环境(IntelliJ IDEA)maven+jetty+jsp(我已经尝试把官demo的jar的依赖都加进去了但还是不能renderJSP )的依赖?
2. pom.xml 里面 jetty server的依赖的groupid用com.jfinal和用org.eclipse.jetty区别是什么?(如果把jfinal的jettey改成相同版本的eclipse的jetty则启动报错: Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/webapp/WebAppContext )
@JFinal 或者谁能帮忙? 谢谢
Idea你就用你的 jetty-maven-plugin插件启动就好了。
pom里面 jetty-serverscope加上另外把JFinal和 junit留下,其他的去掉。加上这个:
<dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency>
启动方法看图。
下面给出dependency:
<!--JettyJSP:根据DependencyHierarchy视图拆分成了七个dependency,-方便项目以及便于导出war的在jetty与tomcat间无缝迁移-Dependencies:http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-jsp<dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-jsp</artifactId><version>8.1.8.v20121106</version><scope>provided</scope></dependency>--><dependency><!--jetty-server-8.1.8开发时JSP支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.servlet.jsp</artifactId><version>2.2.0.v201112011158</version><scope>provided</scope></dependency><dependency><!--jetty-server-8.1.8开发时JSP支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>org.apache.jasper.glassfish</artifactId><version>2.2.2.v201112011158</version><scope>provided</scope></dependency><dependency><!--jetty-server-8.1.8开发时JSP支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.el</artifactId><version>2.2.0.v201108011116</version><scope>provided</scope></dependency><dependency><!--jetty-server-8.1.8开发时JSP支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>com.sun.el</artifactId><version>2.2.0.v201108011116</version><scope>provided</scope></dependency><dependency><!--jetty-server-8.1.8开发时JSP支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>org.eclipse.jdt.core</artifactId><version>3.7.1</version><scope>provided</scope></dependency><dependency><!--JSTL支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.servlet.jsp.jstl</artifactId><version>1.2.0.v201105211821</version><exclusions><!--避免导出servletjar包--><exclusion><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.servlet</artifactId></exclusion></exclusions></dependency><dependency><!--JSTL支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>org.apache.taglibs.standard.glassfish</artifactId><version>1.2.0.v201112081803</version><exclusions><!--避免导出servletjar包--><exclusion><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.servlet</artifactId></exclusion></exclusions>下面给出dependency:
<!--JettyJSP:根据DependencyHierarchy视图拆分成了七个dependency,-方便项目以及便于导出war的在jetty与tomcat间无缝迁移-Dependencies:http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-jsp<dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-jsp</artifactId><version>8.1.8.v20121106</version><scope>provided</scope></dependency>--><dependency><!--jetty-server-8.1.8开发时JSP支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.servlet.jsp</artifactId><version>2.2.0.v201112011158</version><scope>provided</scope></dependency><dependency><!--jetty-server-8.1.8开发时JSP支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>org.apache.jasper.glassfish</artifactId><version>2.2.2.v201112011158</version><scope>provided</scope></dependency><dependency><!--jetty-server-8.1.8开发时JSP支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.el</artifactId><version>2.2.0.v201108011116</version><scope>provided</scope></dependency><dependency><!--jetty-server-8.1.8开发时JSP支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>com.sun.el</artifactId><version>2.2.0.v201108011116</version><scope>provided</scope></dependency><dependency><!--jetty-server-8.1.8开发时JSP支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>org.eclipse.jdt.core</artifactId><version>3.7.1</version><scope>provided</scope></dependency><dependency><!--JSTL支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.servlet.jsp.jstl</artifactId><version>1.2.0.v201105211821</version><exclusions><!--避免导出servletjar包--><exclusion><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.servlet</artifactId></exclusion></exclusions></dependency><dependency><!--JSTL支持--><groupId>org.eclipse.jetty.orbit</groupId><artifactId>org.apache.taglibs.standard.glassfish</artifactId><version>1.2.0.v201112081803</version><exclusions><!--避免导出servletjar包--><exclusion><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.servlet</artifactId></exclusion></exclusions>@如梦技术,问一个相关问题intellij如何设置自动编译,像这样设置无效:http://www.360doc.com/content/14/1110/08/16002580_423959393.shtml
否则每次改java需要手动点make麻烦
@如梦技术,问一个相关问题intellij如何设置自动编译,像这样设置无效:http://www.360doc.com/content/14/1110/08/16002580_423959393.shtml
否则每次改java需要手动点make麻烦
这里再补充一下,新版本jfinal在用整合的 Jetty启动时,需要使用下面的depencency,前面给出的不再适用:
<!--jspsupportbyjetty--><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-jsp</artifactId><version>8.1.8.v20121106</version><scope>provided</scope></dependency>
如果是IDEA下开发,要将scope改成compile,在打war包时注意要再改回来成为provided,独立部署用的容器大多都有jsp支持的jar包
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。