Eclipse Maven Weblogic热代码交换 [英] Eclipse Maven Weblogic hot code swap

查看:186
本文介绍了Eclipse Maven Weblogic热代码交换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基本的问题,关于在eclipse中使用maven在Weblogic上运行Java EE应用程序。



我使用OEPE(Oracle Enterprise Pack for Eclipse)插件,如m2e和wtp。据我所知,这个插件读取pom文件并根据它们构建jar,war和ear文件。



我现在做的是这样的:



我自动检查构建选项,让这些插件创建我的EAR文件,然后在Eclipse中右键单击weblogic服务器的实例,并使用add / remove选项将其添加到服务器,最后启动应用程序服务器。这样,当我更改代码在我的类,他们将被应用程序服务器和热插拔工作。



构建EAR文件的另一种方法是使用m2e插件:右键单击父pom文件,然后选择maven install,然后启动应用程序服务器,并使用wls:deploy以便部署EAR文件。 (这一次,我没有将Eclipse文件添加到Eclipse中的应用程序服务器中,当我右键单击IDE中的weblogic实例时,eclipse也不知道那个EAR文件)。



据我所见,我只能将这些工件添加到使用wtp插件构建的服务器上,而不是使用maven命令m2e插件构建的工件。 wtp和所有这些插件(实际上只是运行mvn -install的m2e除外)的问题是它们无法正常工作。有时他们不会正确构建工件,有时jar文件已经过时,而且没有被更新。此外,当您在另一个maven项目中使用一个项目的jar文件时,在更改之前卡住了jar文件,而在使用m2e时,它们完美无缺地构建。



现在这里是真正的问题:



哪个方法是正确的部署?我/我缺少一些东西?



使用m2e插件构建ear文件并使用wls部署:部署足够?如果是这样,热插拔自身会发生什么,还是应该使用wls:每次重新部署?如果m2e是足够的,那么我假设我应该放弃wtp插件(它不知道所有的pom文件的插件,我有时应该将它们标记为在eclipse的生命周期管理xml文件中被忽略)。



我很抱歉这个问题很久,但我希望我清楚了解并得到一些帮助。

解决方案

让我提供我的清单,使我的Web应用程序在Weblogic上部署。这个清单假定一个weblogic版本实现了Servlet 2.5,并假定你的项目是一个maven,它被配置为运行JDK 1.6的maven-compiler-plugin。
换句话说,您的weblogic版本为10.xx,您的POM包含以下代码段:

 < groupId> org.apache.maven.plugins< /&的groupId GT; 
< artifactId> maven-compiler-plugin< / artifactId>
< version> 2.3.2< / version>
< configuration>
< source> 1.6< / source>
< target> 1.6< / target>
< / configuration>



建立战争



使用OEPE插件来创建一个新的Weblogic Web模块Weblogic.xml文件:




  • 不启用弹簧扩展

  • 在FastSwap中:不要启用类重新定义

  • 记下值

     < WLS:上下文根> myappcontextroot< / WLS:上下文根> 

    它将在稍后的热部署中使用




从项目的Eclipse上下文菜单执行Maven更新项目



执行Maven clean install



对于热部署设置:




  • 将本地weblogic作为运行时服务器添加到Windows->首选项 - >服务器 - >运行系统。记住将其Java主机更改为Sun JDK而不是JRocket进行开发模式。

  • 在Server-> add server中添加本地服务器

  • 项目上下文菜单 - >属性 - >项目方面 - >添加分面性质

  • 确保Jave Facet是1.6版

  • 检查动态Web应用程序版本2.5,并使目标运行时是在第一步中声明的运行时服务器+在进一步的配置中给出上下文根,上面提到的值为myappcontextroot,并给出内容目录值src\main\webapp。不要生成web.xml,否则您的web.xml被覆盖

  • 按OK将所有上述方面的更改应用到您的项目

  • 再次打开项目上下文菜单 - >属性 - >部署程序集 - >添加java构建路径 - > Maven依赖关系

  • 最后,在服务器窗口中将配置的应用程序添加到正在运行的服务器



请按照这些步骤,真的值得!


I have a basic question about running a Java EE application on Weblogic using maven in eclipse.

I use OEPE (Oracle Enterprise pack for Eclipse) which comes with some plugins such as m2e and wtp. As far as I know this plugins read the pom file and based on them build the jar, war and ear files.

What I do right now is like this:

I check the build automatically option and let these plugins create my EAR file, then right click on the instance of weblogic server in Eclipse and add it to server using add/remove option and finally start the application server. This way when I change code in my classes they will be picked by application server and hot swap works.

Another way to build the EAR file is using the m2e plugin: right click on the parent pom file and choose maven install then start the application server and use the wls:deploy in order to deploy the EAR file. (This time I don't add the ear file to the application server from within the Eclipse and eclipse also is not aware of that EAR file when I right click on the instance of my weblogic inside the IDE).

As far as I've seen I can only add those artifacts to server which are built using the wtp plugin and not the artifacts that are built using maven command of m2e plugin. The problem with wtp and all these plugins (except for m2e which actually just runs mvn -install) is that they don't work flawlessly. Sometimes they don't build the artifacts correctly sometimes the jar files are obsolete and they don't get updated. Moreover when you use the jar file of one project in another maven project they get stuck with the jar file prior to your changes, while using the m2e they are built flawlessly.

Now here is the real question:

Which way is the correct one to have hot deploy?

Am I missing something? Is building the ear file using m2e plugin and deploying using wls:deploy enough? If so how will hot swap happen by itself or should i use wls:redeploy each time? If m2e is enough then I assume that I should abandon wtp plugin (it does not know all the plugins of pom file and I should sometimes mark them as ignored in lifecycle management xml file of eclipse).

I'm sorry that the question is that long but I hope that I made the case clear and get some help!

解决方案

Let me provide you with my checklist to make my web application hot-deployed on Weblogic. This checklist assumes a weblogic version which implements Servlet 2.5 and assumes your project is a maven one which is configured to run maven-compiler-plugin for JDK 1.6. In other words your weblogic version is 10.x.x and your POM includes the following snippet:

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
    <source>1.6</source>
    <target>1.6</target>
</configuration>

To build a war

Use OEPE plugin to create a new Weblogic Web module Weblogic.xml file:

  • Don’t enable spring extension
  • In FastSwap: Don’t enable class redefinition
  • Take note of the value

    <wls:context-root>myappcontextroot</wls:context-root> 
    

    it will be used later in the hot-deployment

Execute Maven update project from Eclipse context menu of your project

Execute Maven clean install

For hot-deployment setup:

  • Add local weblogic as a runtime server in Windows->preferences->Server->Runtime. Remember to change its Java home to the Sun JDK instead of JRocket for development mode.
  • Add local server in Server->add server
  • Project context menu->properties->Project Facet-> add faceted nature
  • Make Sure Jave Facet is version 1.6
  • Check Dynamic web application version 2.5 and make the target runtime be the runtime server declared in the first step + In further configuration give "context root" the value "myappcontextroot" which was noted above and give "Content directory" the value "src\main\webapp". Don't generate web.xml otherwise your web.xml is overwritten
  • Push OK to apply all the above facet changes to your project
  • Again open Project context menu->properties->Deployment Assembly->Add java build path->Maven dependencies
  • Finally, in the server window Add configured application to the running server

Please follow these steps literally, it is really worth it!

这篇关于Eclipse Maven Weblogic热代码交换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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