编程小贴士

给你的编程提供小点子


eclipse创建maven的web工程

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

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

tips1000_2014-07-02_05-20-24

 

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

        tips1000_2014-07-02_05-20-25

 

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

        tips1000_2014-07-02_05-20-241

 

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

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

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

tips1000_2014-07-02_05-20-253

 

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

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

tips1000_2014-07-02_05-20-251

 

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

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

tips1000_2014-07-02_05-20-252

 

tips1000_2014-07-02_05-20-27

 

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版本

        tips1000_2014-07-02_05-20-271

tips1000_2014-07-02_05-20-272

 

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

tips1000_2014-07-02_05-20-281

 

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

tips1000_2014-07-02_05-20-28

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

tips1000_2014-07-02_05-20-282

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

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

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

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

设置完成效果图

tips1000_2014-07-02_05-20-30

 

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跑即可

160 Responses to “ eclipse创建maven的web工程 ”

  1. me suba说道:

    Nd1WxH Perhaps you can write next articles referring to this article.

  2. Regards for all your efforts that you have put in this. Very interesting info.

  3. bot gao lut说道:

    It as not that I want to copy your web-site, but I really like the style and design. Could you tell me which style are you using? Or was it especially designed?

  4. animal drawings说道:

    Thanks-a-mundo for the post.Really thank you! Much obliged.

  5. Lung Detox说道:

    Thank which you bunch with regard to sharing this kind of with all you genuinely admit a minute ago what you are speaking approximately! Bookmarked. Entertain also obtain guidance from my web page

  6. You made some first rate points there. I regarded on the web for the problem and found most individuals will go along with together with your website.

  7. sayt krovla说道:

    Major thanks for the blog.Really thank you! Much obliged.

  8. Some truly select posts on this internet site , saved to favorites.

  9. the comments appаА аЂа•ar as if they are coming fr?m brain

  10. Oluwadamilare说道:

    Thanks a lot for the article.Really looking forward to read more. Will read on

  11. This excellent website definitely has all the information and facts I wanted concerning this subject and didn at know who to ask.

  12. Nice blog here! Additionally your website loads up very fast! What web host are you the usage of? Can I get your associate link to your host? I want my website loaded up as fast as yours lol

  13. You may have a very good layout for the blog i want it to utilize on my web site as well

  14. buy说道:

    I’а†ve read many excellent stuff here. Unquestionably worth bookmarking for revisiting. I surprise how a great deal try you set to create this sort of great informative internet site.

  15. w88world.com说道:

    I seriously love your blog.. Excellent colors

  16. kovanie elementy说道:

    Some truly nice stuff on this internet site, I enjoy it.

  17. Wow! Thank you! I constantly wanted to write on my website something like that. Can I implement a portion of your post to my blog?

  18. Music started playing anytime I opened up this web-site, so irritating!

  19. We stumbled over here by a different page and thought I might check things out. I like what I see so i am just following you. Look forward to exploring your web page again.

  20. This website really has all the information I wanted about this subject and didn at know who to ask.

  21. woking cab说道:

    SHINeeWorld PHILIPPINES Goods Notice SWPH Goods

  22. Wow, marvelous blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your web site is excellent, let alone the content!

  23. This unique blog is obviously entertaining additionally diverting. I have discovered a bunch of useful things out of this blog. I ad love to go back every once in a while. Thanks a bunch!

  24. Wow! This could be one particular of the most useful blogs We ave ever arrive across on this subject. Basically Fantastic. I am also a specialist in this topic therefore I can understand your effort.

  25. The Lost Ways说道:

    I used to be able to find good advice from your blog articles.

  26. moment this time I am visiting this web site and reading very informative posts here.

  27. PhD Green Card说道:

    this, such as you wrote the book in it or something.

  28. Share说道:

    Pretty nice post. I just stumbled upon your weblog and wished to say that I ave really enjoyed browsing your blog posts. After all I all be subscribing to your feed and I hope you write again soon!

  29. Well I definitely enjoyed studying it. This post provided by you is very useful for proper planning.

  30. Nwokolo说道:

    Look complex to more delivered agreeable from you!

  31. klm voucher说道:

    Thanks for sharing, this is a fantastic blog.Really thank you! Cool.

  32. unintentionally, and I am stunned why this accident did not happened in advance! I bookmarked it.

  33. indeed, investigation is having to pay off. So happy to possess found this article.. of course, analysis is having to pay off. Wonderful thoughts you possess here..

  34. metal recycling说道:

    Im grateful for the blog article.Much thanks again. Really Great.

  35. MP3 Downloads说道:

    I seriously like your way of writing a blog. I saved as a favorite it to

  36. Say, you got a nice blog article.Really thank you! Really Great.

  37. visit website说道:

    Major thanks for the blog.Much thanks again. Really Great.

  38. Im thankful for the post.Thanks Again. Will read on

  39. Thank you ever so for you article.Really thank you! Much obliged.

  40. to read more说道:

    I respect your work, regards for all the interesting blog posts.

  41. this website说道:

    Your content is excellent but with pics and videos, this site could definitely be one of the most beneficial

  42. respective fascinating content. Make sure you update this

  43. sales tool说道:

    louis vuitton wallets ??????30????????????????5??????????????? | ????????

  44. thao duoc quy说道:

    You made some good points there. I did a search on the subject matter and found most individuals will go along with with your blog.

  45. I think this is a real great blog post.Thanks Again. Cool.

  46. Nice info! Also visit my blog about Clomid challenge test

  47. There is noticeably a bundle to find out about this. I assume you made sure good factors in features also.

  48. Thanks for the article.Thanks Again. Will read on

  49. IPTV说道:

    It as best to participate in a contest for probably the greatest blogs on the web. I will recommend this site!

  50. Miracle Ndu说道:

    Thanks for sharing, this is a fantastic article.Much thanks again. Really Cool.

  51. fitness说道:

    This actually answered my own problem, thank an individual!

  52. Rental Dress说道:

    Im thankful for the blog article.Much thanks again. Much obliged.

  53. remedy additional eye mark complications in order that you can readily get essentially the most from your hard earned money therefore you all certainly hold the product as full impacts.

  54. wow, awesome post.Much thanks again. Really Great.

  55. Thanks for helping out and about, superb data. The a number of stages regarding man are generally infancy, childhood, adolescence, and obsolescence. by Bruce Barton.

  56. Crochet facil说道:

    Wow, great article.Much thanks again. Keep writing.

  57. online说道:

    Perfect piece of work you have done, this site is really cool with fantastic info.

  58. red shoes说道:

    Real fantastic information can be found on site. I can think of nothing less pleasurable than a life devoted to pleasure. by John D. Rockefeller.

  59. worth说道:

    What could you suggest in regards to your submit that you just made a few days in

  60. It as not that I want to copy your web-site, but I really like the layout. Could you tell me which style are you using? Or was it tailor made?

  61. Waec说道:

    Very good information. Lucky me I came across your blog by accident (stumbleupon). I ave book-marked it for later!

  62. School admission说道:

    Rattling great information can be found on weblog.

  63. This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information. Thanks for this nice article.

  64. This awesome blog is without a doubt cool additionally informative. I have picked up a bunch of handy advices out of it. I ad love to go back again soon. Thanks a bunch!

  65. Im grateful for the post.Really looking forward to read more. Really Cool.

  66. Looking forward to reading more. Great article post.Really looking forward to read more. Really Great.

  67. Maybe in the future it all do even better in those areas, but for now it as a fantastic way to organize and listen to your music and videos,

  68. Open heaven说道:

    Spot on with this write-up, I really assume this website needs rather more consideration. I all most likely be again to learn rather more, thanks for that info.

  69. tm objection说道:

    The world hopes for more passionate writers like you who aren at afraid to say how they believe. At all times follow your heart.

  70. Very neat post.Much thanks again. Want more.

  71. motorcycle accident claims What college-university has a good creative writing program or focus on English?

  72. I truly appreciate this post. I ave been seeking everywhere for this! Thank goodness I found it on Google. You have created my day! Thx once again..

  73. Very informative blog.Thanks Again. Awesome.

  74. I really liked your blog post.Really looking forward to read more. Will read on

  75. Really informative article post.Really looking forward to read more. Fantastic.

  76. free browsing说道:

    Wonderful put up, definitely regret not planning towards the USO style dinner. Keep up the excellent get the job done!

  77. Merely wanna remark that you have a very nice web site , I like the pattern it actually stands out.

  78. hotel说道:

    There is definately a lot to learn about this subject. I love all of the points you have made.

  79. Wanted to drop a comment and let you know your Feed isnt functioning today. I tried adding it to my Yahoo reader account but got nothing.

  80. Normally I don at learn article on blogs, however I would like to say that this write-up very pressured me to check out and do so! Your writing style has been surprised me. Thanks, quite nice post.

  81. wonderful issues altogether, you just received a logo new reader. What may you suggest in regards to your submit that you just made some days ago? Any positive?

  82. Really enjoyed this post.Much thanks again. Awesome.

  83. Wohh precisely what I was searching for, regards for posting.

  84. This very blog is really awesome and also amusing. I have chosen a lot of handy things out of this source. I ad love to come back again soon. Thanks!

  85. It as hard to find experienced people about this topic, however, you seem like you know what you are talking about! Thanks

  86. devotionals说道:

    Looking forward to reading more. Great article.Really looking forward to read more. Great.

  87. official site说道:

    Thanks-a-mundo for the blog article.Really looking forward to read more. Great.

  88. Very good info. Lucky me I found your blog by chance (stumbleupon). I ave book-marked it for later!

  89. This is really interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your fantastic post. Also, I ave shared your website in my social networks!

  90. This is one awesome blog post.Thanks Again. Will read on

  91. Wow, fantastic blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your site is fantastic, let alone the content!

  92. more info说道:

    You, my pal, ROCK! I found just the information I already searched everywhere and simply could not find it. What an ideal site.

  93. Looking around I like to browse in various places on the web, regularly I will go to Digg and follow thru

  94. Lastly, an issue that I am passionate about. I ave looked for data of this caliber for that previous various hrs. Your site is tremendously appreciated.

  95. visit website说道:

    Looking forward to reading more. Great blog.Really thank you!

  96. Pretty! This has been an incredibly wonderful article. Thank you for providing this info.

  97. Your style is really unique compared to other people I ave read stuff from. Thanks for posting when you ave got the opportunity, Guess I will just book mark this blog.

  98. You could certainly see your skills in the work you write. The world hopes for even more passionate writers like you who aren at afraid to say how they believe. Always follow your heart.

  99. This very blog is obviously cool and diverting. I have discovered many useful tips out of it. I ad love to visit it again soon. Cheers!

  100. Im obliged for the blog.Really looking forward to read more. Really Great.

  101. I wanted to thank you for this very good read!! I definitely enjoyed every bit of it. I ave got you saved as a favorite to check out new things you post

  102. share说道:

    Major thankies for the article.Thanks Again. Awesome.

  103. Okey说道:

    Well I truly enjoyed studying it. This article procured by you is very constructive for proper planning.

  104. UVB Narrowband Treatment Is a computer science degree any good for computer forensics?

  105. free advertising说道:

    This blog is really cool and besides informative. I have chosen a lot of useful advices out of this amazing blog. I ad love to visit it over and over again. Thanks!

  106. This awesome blog is no doubt awesome additionally informative. I have chosen helluva helpful things out of this amazing blog. I ad love to go back again soon. Cheers!

  107. for details说道:

    Major thankies for the blog article. Awesome.

  108. check out说道:

    Lovely website! I am loving it!! Will be back later to read some more. I am bookmarking your feeds also

  109. This is a beautiful picture with very good lighting

  110. You ave made some good points there. I looked on the net for more

  111. Muchos Gracias for your article. Will read on

  112. link说道:

    to start my own blog in the near future. Anyway, if you have any suggestions or techniques for new blog owners please

  113. your intelligence on just posting videos to your site when you could be giving

  114. Major thanks for the article post.Really thank you! Really Great.

  115. cau do说道:

    Thanks so much for the post.Much thanks again. Awesome.

  116. more info说道:

    Just Browsing While I was browsing today I saw a great article about

  117. Your weblog is wonderful dude i love to visit it everyday. very good layout and content material ,

  118. tampa seo说道:

    On the outside its measures are an even dozen point-five inches in diameter on six point-five toaster oven reviews centimeters heavy.

  119. website who has shared this enormous piece of writing at

  120. genuine parts说道:

    This very blog is obviously cool as well as diverting. I have discovered helluva helpful things out of it. I ad love to return every once in a while. Thanks a bunch!

  121. click here说道:

    I think other web-site proprietors should take this web site as an model, very clean and excellent user friendly style and design, let alone the content. You are an expert in this topic!

  122. have a nice day说道:

    Keep up the great work , I read few posts on this internet site and I believe that your blog is rattling interesting and contains bands of great information.

  123. Im grateful for the article post.Thanks Again. Keep writing.

  124. There is definately a lot to find out about this topic. I love all the points you made.

  125. You ave made some good points there. I looked on the internet to find out more about the issue and found most individuals will go along with your views on this website.

  126. This blog is definitely cool and factual. I have discovered many interesting stuff out of this source. I ad love to visit it every once in a while. Cheers!

  127. your articles. Can you recommend any other blogs/websites/forums that cover the same subjects?

  128. You have brought up a very fantastic details , thankyou for the post. Wit is educated insolence. by Aristotle.

  129. This very blog is no doubt educating and also informative. I have picked helluva useful stuff out of this blog. I ad love to go back over and over again. Thanks!

  130. Game Online说道:

    Very good article! We will be linking to this particularly great article on our site. Keep up the good writing.

  131. Canon 1300d说道:

    This is really interesting, You are a very skilled blogger. I ave joined your feed and look forward to seeking more of your magnificent post. Also, I ave shared your website in my social networks!

  132. welcome to wholesale mac makeup from us.

  133. You made some clear points there. I looked on the internet for the topic and found most persons will agree with your blog.

  134. right now说道:

    This is a good tip especially to those new to the blogosphere. Short but very precise info Many thanks for sharing this one. A must read post!

  135. Im obliged for the article.Thanks Again. Cool.

  136. kouponkabla.com说道:

    The new Zune browser is surprisingly good, but not as good as the iPod’s. It works well, but isn’t as fast as Safari, and has a clunkier interface. If you occasionally plan on using the web browser that’s not an issue, but if you’re planning to browse the web alot from your PMP then the iPod’s larger screen and better browser may be important.

  137. Barcode Scanner说道:

    This is a really good tip particularly to those new to the blogosphere. Short but very precise info Thank you for sharing this one. A must read article!

  138. Very good post! We are linking to this great content on our site. Keep up the good writing.

  139. Looks like these guys have plenty of outsourcing opportunities available.

  140. Poker Galaxy说道:

    Say, you got a nice blog article.Much thanks again. Want more.

  141. bo dam说道:

    Thanks-a-mundo for the post.Thanks Again. Fantastic.

  142. KS说道:

    some cheap softwares some cheap softwares does not offer good online technical support so i would caution about using them`

  143. Thanks for the blog post.Thanks Again. Great.

  144. Usually I do not learn post on blogs, however I wish to say that this write-up very forced me to try and do it! Your writing style has been surprised me. Thanks, quite nice post.

  145. of the subjects you write related to here. Again, awesome web site!

  146. Looking forward to reading more. Great blog article.Thanks Again. Cool.

  147. Well I really liked reading it. This article offered by you is very constructive for proper planning.

  148. Very good article. I will be experiencing a few of these issues as well..

  149. chocopie说道:

    8EqEbG Really enjoyed this blog post.Thanks Again. Want more.

  150. we came across a cool web site which you could love. Take a appear when you want

  151. Your style is so unique in comparison to other folks I ave read stuff from. Many thanks for posting when you ave got the opportunity, Guess I all just bookmark this blog.

  152. You can certainly see your enthusiasm within the work you write.

  153. When you can grab my attention in the first few words of an article it as an accomplishment. You ave ignited my interest on this subject and I thank you for this.

  154. This is one awesome post.Much thanks again. Really Great.

  155. You are my function designs. Many thanks for the write-up

  156. Very educating story, I do believe you will find a issue with your web sites working with Safari browser.

  157. Thank you ever so for you article post.Much thanks again. Fantastic.

  158. bistro masa说道:

    Thanks for the post.Thanks Again. Really Cool.

  159. bistro masa说道:

    to do with Lady gaga! Your own stuffs nice.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>