简体   繁体   English

仅部署Java文件而不部署WAR

[英]Deploy only java file without deploying the WAR

I have a jsp based web application. 我有一个基于jsp的Web应用程序。

The source is kept in C:/MyApp/src . 源代码保存在C:/MyApp/src Here it contains the controllers and other .java files. 这里包含控制器和其他.java文件。

After building the application via eclipse. 通过Eclipse构建应用程序之后。 I copied the .war file to Apache/WebApps folder. 我将.war文件复制到Apache/WebApps文件夹。 Apache Tomcat expanded it and the web-application is working perfectly. Apache Tomcat对其进行了扩展,并且该Web应用程序运行正常。

From the last couple of days I edited a lot of pages directly in Apache/WebApps folder. 从最近几天开始,我直接在Apache/WebApps文件夹中编辑了许多页面。 Now I want to edit a .java file in C:/MyApp/src/.. 现在,我想在C:/MyApp/src/..编辑一个.java文件C:/MyApp/src/..

Now I want to use that updated .java file in my Apache/WebApps but don't want to rebuild the whole code via eclipse. 现在,我想在我的Apache/WebApps使用该更新的.java文件,但不想通过eclipse重建整个代码。 If I do so my changes that I made in Apache/WebApps folder will be lost. 如果这样做,我在Apache/WebApps文件夹中所做的更改将丢失。

What should I do? 我该怎么办?

you should 你应该

  1. merge back all you modifications from the deployment folder (Apache/WebApps) to the source folder (C:/MyApp/src/). 将所有修改从部署文件夹(Apache / WebApps)合并回源文件夹(C:/ MyApp / src /)。 Make sure you can rebuild the current version from the sources. 确保可以从源代码重建当前版本。
  2. start using some sort a version control tool, even if you work only on your local machine (I recommend Git ) 开始使用某种版本控制工具,即使您仅在本地计算机上工作(我建议使用Git
  3. start using build tool , instead of having Eclipse build your war from the sources. 开始使用build工具 ,而不是让Eclipse从源头构建您的战争。 I recommend Maven or Ivy 我推荐MavenIvy

Follow the changes as suggested by @bpgergo or else ... 按照@bpgergo的建议进行更改,否则...

You can configure your tomcat server with Eclipse and are starting and stopping the server from eclipse then you can add your project to the configured Server in eclipse. 您可以使用Eclipse配置tomcat服务器,并从eclipse启动和停止服务器,然后可以在eclipse add your project到已配置的Server。

Eclipse can be configured to auto-deploy the changes to the server, so whenever you change anything like a JSP or a java file the server will automatically take the changes without you deploying your WAR file. 可以将Eclipse配置为自动将更改部署到服务器,因此,无论何时更改JSP或Java文件之类的内容,服务器都将自动进行更改,而无需部署WAR文件。

But since java changes are not hot-deployable eclipse would restart the server whenever you save changes to your java file. 但是由于Java更改不是可热部署的,因此每当您将更改保存到Java文件时,Eclipse都会重新启动服务器。

If you want to deploy java changes without restarting the server you can also try using JRebel (it is free for 30 days :-)). 如果要在不重新启动服务器的情况下部署Java更改,也可以尝试使用JRebel (30天免费:-)。

For now I would suggest (if you don't want to go the above mentioned way. The following is a very crude method and should be avoided in the future) 现在,我建议 (如果您不想采用上述方式。以下是非常粗略的方法,将来应避免使用)

  1. compile the .java file into a .class in eclipse. 在eclipse中将.java文件编译成.class
  2. shut-down the server 关闭服务器
  3. copy the .class file to the exact location on the server in WEB-INF/classes/.. .class文件复制到WEB-INF/classes/..服务器上的确切位置WEB-INF/classes/..
  4. restart the server 重新启动服务器
  5. This would keep your JSP changes intact and also will reflect the .java changes 这将使您的JSP更改保持完整,并且还将反映.java更改

Hope this helps. 希望这可以帮助。

Install the Plugin 安装插件

http://andrei.gmxhome.de/filesync/index.html

And work with extracted war-files. 并处理提取的战争文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM