如何使用Eclipse将Maven Project的WAR部署到JBoss服务器? [英] How to deploy WAR of Maven Project to JBoss server from Eclipse?

查看:505
本文介绍了如何使用Eclipse将Maven Project的WAR部署到JBoss服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将WAR的Maven项目部署到JBoss服务器上。我知道从Eclipse Export-> War将WAR文件部署到JBoss。但是我如何为Maven项目做这个。任何一步一步的信息或有用的网站链接将对我非常有帮助。谢谢。



编辑:我添加了

 < plugin> ; 
< groupId> org.codehaus.mojo< / groupId>
< artifactId> jboss-maven-plugin< / artifactId>
< version> 1.5.0< / version>
< configuration>
< jbossHome> / home / tanmoy / Jboss< / jbossHome>
< serverName> all< / serverName>
< fileName> target / LoginExample-1.0.war< / fileName>
< / configuration>
< / plugin>

对我的pom.xml和再次导入为maven项目,但右键单击pom.xml为运行我没有看到任何部署选项。

解决方案

我找到了解决方案,我正在分享,因为它可能是有帮助的给某人。
我的配置是:


  1. Fedora 14

  2. Eclipse Helios for Java EE

  3. JBoss 4.2.0-GA

您还需要


  1. 在系统中安装maven

  2. 在Eclipse中安装m2eclipse插件

现在您可以开始创建项目。


  1. 打开Eclipse->选择您的工作区

  2. 设置服务器。设置服务器


    1. 得到窗口 - >显示视图 - >服务器

    2. 右键单击服务器窗格,选择新建 - >服务器

    3. 从打开的窗口中选择JBoss-> JBoss v4.2

    4. 点击下一步

    5. 浏览应用程序服务器目录,即JBoss所在的文件系统中的位置。

    6. 单击完成


  3. 创建一个新的动态Web项目,创建项目


    1. 转到文件 - >新建 - >项目,选择Web节点下的动态Web项目

    2. 单击下一步

    3. 提供项目名称

    4. 从Target运行时选择JBoss v4.2

    5. 单击下一步两次

    6. 您将需要web.xml,因此请确保在最后一页中检查生成web.xml部署描述符。

    7. 单击完成,Eclipse将为您创建一个动态Web项目


  4. 现在,您需要为创建的项目启用Maven依赖关系管理。要执行此操作


    1. 右键单击项目名称

    2. 选择Maven->启用依赖关系管理

    3. 将打开POM创建窗口

    4. 从包装下拉菜单中选择战争

    5. 单击完成,您的pom.xml将被创建


  5. 它会弄乱你的构建路径。要修复它


    1. 右键单击项目名称,然后转到属性

    2. 从左窗格选择Java构建路径

    3. 转到库选项卡

    4. 编辑JRE系统库。要编辑系统库


      1. 选择JRE系统库并单击右侧的编辑按钮

      2. 从下拉菜单中选择执行环境JavaSE-1.6,
      3. 单击完成


    5. 转到源选项卡


      1. 单击添加文件夹

      2. 选择src

      3. 单击确定,您的项目准备就绪



      4. 现在添加一些源文件,配置web.xml和pom.xml并将其作为WAR导出到JBoss服务器。要部署它


        1. 首先将所有需要的jar复制到WEB-INF中的lib文件夹

        2. 无论何时添加依赖关系到pom.xml Mavan将下载所需的jar并添加到您的项目中。您可以通过扩展节点Project-> Java Resource-> Libraries-> Maven Dependencies来查看这些jar。每个jar文件旁边都提供了路径到jar。它通常位于/.m2/repository中。您可以将这些文件复制到上述的lib文件夹中。

        3. 现在右键单击项目名称

        4. 选择Export-> WAR文件

        5. 在目的地浏览您的服务器的路径

        6. 单击完成,它将WAR文件部署到JBoss服务器。

        注意:有一些可能的重叠jar的jar与JBoss的lib的jar()的一些可能性。那么你应该采取适当的行动。像从你的WAR中删除jar(如果你的jar版本与JBoss的版本相同或更低),或者替换JBoss的jar并从你的WAR中删除那个jar(如果您的jar的版本高于JBoss的版本)。我应该小心,并在做任何事情之前收集知识。



        谢谢。


        I want to deploy WAR of Maven project to JBoss server. I know that from Eclipse Export->War deploy the WAR file to JBoss. But How can I do this for Maven Project. Any step by step information or useful website link will be very helpful to me. Thank you.

        Edit: I have added

        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jboss-maven-plugin</artifactId>
        <version>1.5.0</version>
        <configuration>
            <jbossHome>/home/tanmoy/Jboss</jbossHome>
            <serverName>all</serverName>
            <fileName>target/LoginExample-1.0.war</fileName>
        </configuration>
        </plugin>
        

        To my pom.xml and import again as maven project, but on right clicking into pom.xml for Run As I don't see any option for deployment.

        解决方案

        I found the solution and I am sharing as it might be helpful to someone. My configuration is:

        1. Fedora 14
        2. Eclipse Helios for Java EE
        3. JBoss 4.2.0-GA

        You also need to

        1. Install maven in your system
        2. Install m2eclipse plug-in in your Eclipse

        Now you are ready to start to create project.

        1. Open Eclipse->Choose your Workspace
        2. Set-up server. To set-up server

          1. Got to Window->Show View->Servers
          2. Right click on server pane, select New->Server
          3. Select JBoss->JBoss v4.2 from the window opened
          4. Click Next
          5. Browse Application Server Directory, i.e., the location in your file system where JBoss resides.
          6. Click Finish

        3. Create a new Dynamic Web Project, to create the project

          1. Go to File->New->Project, select Dynamic Web Project under the Web node
          2. Click Next
          3. Give a project name
          4. Select JBoss v4.2 from Target runtime
          5. Click Next twice
          6. You will need web.xml so make sure "Generate web.xml deployment descriptor" is checked in the last page.
          7. Click Finish and Eclipse will create a Dynamic Web Project for you

        4. Now you need to enable Maven Dependency Management for created project. To do this

          1. Right click on the Project name
          2. Select Maven->Enable Dependency Management
          3. A window will be opened for POM creation
          4. Select war from Packaging drop-down menu
          5. Click Finish and your pom.xml will be created

        5. It will messed up your build path. To fix it

          1. Right click on the Project name and go to Properties
          2. Choose Java Build Path from the left pane
          3. Go to Libraries tab
          4. Edit JRE System Library. To edit system library

            1. Select JRE System Library and click Edit button in the right
            2. Choose Execution Environment JavaSE-1.6 from the drop-down menu
            3. Click Finish

          5. Go to Source tab

            1. Click Add Folder
            2. Select src
            3. Click Ok and your project is ready

        6. Now add some source files, configure web.xml and pom.xml and export it to JBoss server as WAR. To deploy it

          1. First copy all required jars to the lib folder in WEB-INF
          2. Whenever you add dependency to pom.xml Mavan will download required jar and add to your project. You can see these jars by expanding nodes Project->Java Resource->Libraries->Maven Dependencies. The path-to-jars are given beside each jar file. It is usually resides in /.m2/repository. You can copy those files into the aforesaid lib folder.
          3. Now right click on Project name
          4. Select Export->WAR file
          5. In Destination browse the path to your server
          6. Click Finish and it will deploy the WAR file into JBoss server.

        Note: there are some possibilities of overlapping jar(s) of your WAR with the jar(s) of JBoss's lib. Then you should take appropriate action. Like remove the jar(s) from your WAR (in case the version of your jar is same or lower than that of JBoss's) or replace the jar(s) of JBoss and remove that jar(s) from your WAR(in case the version of your jar is higher than that of JBoss's). I should be careful about this and gather well knowledge before doing anything.

        Thank you.

        这篇关于如何使用Eclipse将Maven Project的WAR部署到JBoss服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆