eclipse的tomcat运行mave web项目

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

在eclipse中配置maven

安装成功后,就会多出Maven选项,在Installations中添加下载的Maven

在eclipse中配置maven - 熊猫京京 - pansandays weblog

在User Settings中配置本机的默认仓库 

在eclipse中配置maven - 熊猫京京 - pansandays weblog



使用Eclipse的maven构建一个web项目

1、选择建立Maven Project 选择File -> New -> Other,在New窗口中选择 Maven -> Maven Project;点击next

        


2、选择项目路径 Usedefault Workspace location默认工作空间

        


3、选择项目类型 在Artifact Id中选择maven-archetype-webapp

        


4 、输入Group ID和 Artifact ID,以及Package

        Group ID一般写大项目名称。Artifact ID是子项目名称。

        Package是默认给你建一个包,不写也可以

        


5、刚建立好后的文件结构如下图

        如果这里显示的内容多,一般是Filters设置的问题;或perspective为JavaEE模式,改成Java模 式就可以了

        


6、配置项目 需要添加src/main/java,src/test/java ,src/test/resources三个文件夹。右键项目根目录点击New -> Source Folder,建出这三个文件夹

        注意:不是建普通的Folder,而是Source Folder

        


        


7、更改class路径 右键项目,Java Build Path -> Source 下面应该有4个文件夹。src/main/java,src/main /resources,src/test/java ,src/test/resources

        选上Allow output folders for source folders

        双击每个文件夹的Output folder,选择路径

        src/main/java,src/main/resources,选择target/classes;

        src/test/java ,src/test/resources, 选择target/test-classes;        

        在此处还要更改:更改文件夹显示的顺序:点击Order and Export;更改JDK版本:在Libraries双击JRE System Library,要1.6版本

        

        


8、把项目变成Dynamic Web项目 右键项目,选择Project Facets,点击Convert to faceted fro

        


9、配置Project Facets 更改Dynamic Web Module的Version为2.3。(3.0为Java7的)。
        如果提示错误,可能需要在Java Compiler设置Compiler compliance level 为1.6,或者需要在此窗口的Java的Version改成1.6

        

10、设置部署程序集(Web Deployment Assembly)
        上面步骤设置完成后,点击OK,Properties窗口会关 闭,在右键项目打开此窗口。在左侧列表中会出现一个Deployment Assembly,点击进去后,如下图

        

        此处列表是,部署项目时,文件发布的路径。

        (1)我们删除test的两项,因为test是测试使用,并不需要部署。

        (2)设置将Maven的jar包发布到lib下。

        Add -> JavaBuild Path Entries -> Maven Dependencies -> Finish

        设置完成效果图

        


11、构建框架 在pom.xml中添加所需要的jar包

        使用Maven POM editor打开项目中的pom.xml文件,选择Dependencies,在Dependencies栏目点击Add进行,首先弹出一个搜索按钮,例 如输入jsf,就会自动搜索关于JSF相关的jar包,我们选择2.0.4版本的jsf,将jsf包全部添加进来

        需要添加的其他jar包有:junit、jstl

        或者点击pom.xml直接编辑pom.xml文件,这样可以直接copy过来dependencies内容;

        我们的pom.xml文件可直接复制下面的内容:

        <project xmlns="http://maven.apache.org/POM/4.0.0"
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

                <modelVersion>4.0.0</modelVersion>
                <groupId>com.smile.maven.demo</groupId>
                <artifactId>maven-demo-web</artifactId>
                <packaging>war</packaging>
                <version>0.0.1-SNAPSHOT</version>
                <name>maven-demo-web Maven Webapp</name>
                <url>http://maven.apache.org</url>

                <dependencies>
                        <dependency>
                                <groupId>junit</groupId>
                                <artifactId>junit</artifactId>
                                <version>3.8.1</version>
                                <scope>test</scope>
                        </dependency>
                        <dependency>
                                <groupId>com.sun.faces</groupId>
                                <artifactId>jsf-api</artifactId>
                                <version>2.0.4-b09</version>
                        </dependency>
                        <dependency>
                                <groupId>com.sun.faces</groupId>
                                <artifactId>jsf-impl</artifactId>
                                version>2.0.4-b09</version>
                        </dependency>
                        <dependency>
                                <groupId>javax.servlet</groupId>
                                <artifactId>jstl</artifactId>
                                <version>1.2</version>
                        </dependency>
                        <dependency>
                                <groupId>taglibs</groupId>
                                <artifactId>standard</artifactId>
                                <version>1.1.2</version>
                        </dependency>
                </dependencies>

                <build>
                        <finalName>maven-demo-web</finalName>
                </build>

        </project>


12、发布 对着工程点右键:Run As ->Maven install 然后再Run As -> Mavenpackage.
        生成完后用Tomcat跑即可


转载于:https://my.oschina.net/huhaoren/blog/297544

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/546298.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python在shell终端中显示进度条

Python在shell终端中显示进度条简单代码&#xff1a; from time import sleep from tqdm import tqdmmax 100 for i in tqdm(range(max)):sleep(0.1)效果如下&#xff1a;

tanh python_带有Python示例的math.tanh()方法

tanh pythonPython math.tanh()方法 (Python math.tanh() method) math.tanh() method is a library method of math module, it is used to get the hyperbolic tangent of given number in radians, it accepts a number and returns hyperbolic tangent. math.tanh()方法是数…

没用过这些IDEA插件?怪不得写代码头疼

小伙伴们&#xff0c;大家好。今天准备和大家一起分享一下实际工作中常用的几款能提升幸福感和工作效率的IDEA插件吧&#xff0c;也欢迎小伙伴们在评论区安利出你们用过的觉得非常不错的插件&#xff0c;大家一起交流进步。1、Background Image Plus默认IDEA的背景一般都比较单…

颠覆与重构——戴尔助力徐工集团等行业客户实现业务转型

无论在IT领域&#xff0c;还是传统行业&#xff0c;颠覆与重构都是不可回避的话题。利用ICT领域的技术创新与互联网思维&#xff0c;传统企业可以更好地实现业务转型与创新。阿里集团与上汽共研互联网汽车&#xff0c;东软致力于推动远程医疗新模式&#xff0c;Mock颠覆传统学习…

Linux多命令顺序执行与管道符

1.多命令顺序执行 实例测试&#xff1a; 2.管道符 实例测试&#xff1a; 3.grep命令 实例测试&#xff1a; 获取更多技术干货&#xff0c;请访问大土土随笔 如果本文对您有所帮助&#xff0c;请关注微信公众号“捷创源科技”。

math.atan_Python中带有示例的math.atan()方法

math.atanPython math.atan()方法 (Python math.atan() method) math.atan() method is a library method of math module, it is used to get the arc tangent, it accepts a number and returns the arc tangent value (in radians) of the given number. math.atan()方法是数…

99%的程序员都在用Lombok,原理竟然这么简单?我也手撸了一个!|建议收藏

世界上只有一种英雄主义&#xff0c;就是看清生活的真相之后依然热爱生活。 对于 Lombok 我相信大部分人都不陌生&#xff0c;但对于它的实现原理以及缺点却鲜为人知&#xff0c;而本文将会从 Lombok 的原理出发&#xff0c;手撸一个简易版的 Lombok&#xff0c;让你理解这个热…

EasyUI DataGrid 中字段 formatter 格式化不起作用

今天用 EasyUI datagrid 来做列表&#xff0c;要对一些数据进行格式化&#xff0c;推断某字段状态时&#xff0c;发现 formatter 格式化相应的函数不起作用。 <table id"list_data" title"未审核报表" class"easyui-datagrid" style"wid…

PyQt5单击QTableView垂直表头verticalHeader获取行数据以及单击单元格获取行数据操作

PyQt5单击QTableView单元格获取单元格数据,很容易实现,从而可以实现获取这一行的数据。但是单击QTableView垂直表头verticalHeader获取行数据,我摸索了一周时间才解决,下面分享下重点。 1.利用PyCharm及Python语言创建PyQt5主界面 添加tableView控件,编程初始化如下: …

python中acosh_acosh()函数以及C ++中的示例

python中acoshC acosh()函数 (C acosh() function) acosh() function is a library function of cmath header, it is used to find nonnegative area hyperbolic cosine of the given value, it accepts a number (x) and returns the nonnegative area hyperbolic cosine of…

震惊!这样终止线程,竟然会导致服务宕机?

在开始之前&#xff0c;我们先来看以下代码会有什么问题&#xff1f; public class ThreadStopExample {public static void main(String[] args) throws InterruptedException {Thread t1 new Thread(() -> {try {System.out.println("子线程开始执行");// 模拟…

华为交换机系统软件升级和安全漏洞修复教程

华为交换机官网 可以查询到华为交换机官方电话:400-822-9999,通过下面2个命令查询出需要升级的交换机软件版本和补丁版本号发给华为,获取新的升级系统软件和补丁以及升级教程。下面是我升级华为交换机总结的教程,作为参考 <HUAWEI> display version<HUAWEI&g…

python里x.pow2_带有Python示例的math.pow()方法

python里x.pow2Python math.pow()方法 (Python math.pow() method) math.pow() method is a library method of math module, it is used to calculate the given power of a base, it accepts two numbers and returns the first number to the power of the second number in…

想读Spring源码?先从这篇「 极简教程」开始

这是我的第 47 篇原创文章。为什么要阅读源码&#xff1f;这是一个有趣的问题&#xff0c;类似的问题还有&#xff0c;为什么要看书&#xff1f;为什么要爬山&#xff1f;这也是一个哲学问题&#xff0c;我想每个人都有不同的答案&#xff0c;下面我是对阅读源码好处的一些思考…

Linux Shell接收键盘输入

1.read命令格式 read [选项] [变量名] 选项&#xff1a; -p “提示信息”&#xff1a;在等待read输入时&#xff0c;输出提示信息 -t “秒数”&#xff1a; read命令会一致等待用户输入&#xff0c;使用此选项可以指定等待时间 -n “字符数”&#xff1a; read命令只接受指…

机房收费重构之总结篇

《机房收费重构》之路终于接近了尾声&#xff0c;这么一个月的时间做梦都在敲代码。总结《机房收费重构》的道路需要从学习方法&#xff0c;注意问题&#xff0c;知识总结三方面来进行&#xff01; 《机房收费重构》之路的背景&#xff1a; 1.设计模式&#xff1a; 设计模式的思…

带有Python示例的math.exp()方法

Python math.exp()方法 (Python math.exp() method) math.exp() method is a library method of math module, it is used to get the number in exponential form, it accepts a number and returns the number in the exponential format (if the number is x, it returns e*…

想快速拥有个人网站?来试试这个...

一、简介Hugo 是Go语言实现的一款静态网站生成器。它简单、易用、高效、易扩展、快速部署。相比较其他静态网站生成器&#xff0c;它的优点有这几点&#xff1a;项目构建特别快主题目录与站点目录结构一样配置文件为*.toml 格式&#xff0c;语法常简单易懂&#xff0c;没有缩进…

android 类ios actionsheet效果

1.http://blog.csdn.net/zhaoxy_thu/article/details/17733389 2. https://github.com/ojhariddhish/actionsheetdemo

带有Python示例的math.cos()方法

Python math.cos()方法 (Python math.cos() method) math.cos() method is a library method of math module, it is used to get the cosine of the number radians, it accepts a number returns the cosine of the given number radians. math.cos()方法是数学模块的库方法&…