简体   繁体   English

从SVN到服务器上的Tomcat的Java类文件:如何自动编译?

[英]Java Class file from SVN to Tomcat on server: How to compile automatically?

I'm currently fixing a JSP project and it currently has a seemingly random collection of .class files in it's Tomcat's WEB-INF folder. 我正在修复一个JSP项目,它目前在它的Tomcat的WEB-INF文件夹中有一个看似随机的.class文件集合。 As a way of simplifying this, I was planning to get .java files from these classes straight from SVN to WEB-INF folder on server and I got that to work but what would be the simplest way of compiling these? 作为一种简化这种方法的方法,我计划将这些类中的.java文件从SVN直接从服务器上的WEB-INF文件夹中获取,然后我就可以使用它,但是编译这些文件的最简单方法是什么? Of course I could create a cronjob which would compile all the classes during the night but it seems like a bit of hassle. 当然我可以创建一个cronjob,可以在晚上编译所有类,但看起来有点麻烦。

I know that our project management is a bit f*cked up and the correct of deploying applications on to a server would probably be to use WAR files. 我知道我们的项目管理有点过时,将应用程序部署到服务器上的正确可能是使用WAR文件。 I'm trying to fix this in small incremental steps because the project is quite large and in use all the time. 我正在尝试以小的增量步骤来解决这个问题,因为项目非常庞大且一直在使用。

Tomcat only compiles the .jsp files, so you'll have to do the compile the .java files yourself, one way or another. Tomcat只编译.jsp文件,所以你必须自己编译.java文件,无论如何。

Most robust solution would be to create an ant task that built a .war file for the entire project and then pushed that to Tomcat (or use Maven2 to achieve same). 最强大的解决方案是创建一个ant任务,为整个项目构建一个.war文件,然后将其推送到Tomcat(或使用Maven2实现相同)。 While that will require some work now, it will save you a ton of effort in the long run. 虽然这需要一些工作,但从长远来看,它将为您节省大量的工作。

You might consider building a jar file from the *.java files on your build/dev box, then pushing that jar file to the server. 您可以考虑在build / dev框中的* .java文件中构建一个jar文件,然后将该jar文件推送到服务器。 Storing class files in VCS is a really bad idea. 在VCS中存储类文件是一个非常糟糕的主意。

Another approach might be to do the following 另一种方法可能是执行以下操作

Assuming: 假设:

/opt/apache-tomcat/ 的/ opt / Apache的Tomcat的/

Holds your app server, create something like this: 保留您的应用服务器,创建如下内容:

/opt/build/ /选择/构建/

Check out your files into the build directory then use one or more scripts to copy 将文件签出到构建目录中,然后使用一个或多个脚本进行复制

/opt/build/my-app/ --> /opt/apache-tomcat/webapps/my-app/ / opt / build / my-app / - > / opt / apache-tomcat / webapps / my-app /

Once you have that kind of working, try to get a repeatable (and verifiable) build working. 一旦你有了这种工作,尝试使可重复(和可验证)的构建工作。 Ideally a war file. 理想情况下是战争档案。

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

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