从文件系统导入eclipse项目,然后在服务器上运行 [英] importing an eclipse project from file system, then running on server
问题描述
I am trying to do the spring security tutorial at this link.
在标题为没有Spring Security的情况下运行教程应用程序" 的部分中,我采取了以下步骤(针对当前版本与编写教程时使用的版本之间的差异进行了调整):
In the section entitled "Running the Tutorial application without Spring Security", I took the following steps (adjusted for differences between the current version and the version that was in use when the tutorial was written):
1.) I downloaded the latest release of the Spring Security Distribution,
2.) found and unzipped a war file in the dist directory called spring-security-samples-tutorial-3.1.2.RELEASE.war
3.) Renamed the resulting folder spring-security-tutorial
4.) Created a general project in eclipse called spring-security-tutorial
5.) Imported all of the contents of the unzipped spring-security-samples-tutorial-3.1.2.RELEASE.war
6.) Right clicked on the project in eclipse and selected configure...convert to maven project
7.) Then right clicked on the project and clicked run as...
但是没有在服务器上运行"选项.(我选择了一个通用项目而不是一个动态Web项目,以期保留要导入的应用程序的文件结构)
But there was no "run on server" option. (I had chosen a general project instead of a Dynamic Web Project in hopes of preserving the file structure of the application to be imported)
然后我开始重复该过程,但是创建了一个动态Web项目而不是一个普通项目,而eclipse希望我选择构建路径上的src文件夹".Web应用程序的文件结构在WEB-INF的子文件夹中有8个.class文件,但我找不到任何.java文件.
I then started to repeat the process, but creating a Dynamic Web Project instead of a general project, and eclipse wants me to select the "src folders on build path". The file structure of the web application has 8 .class files in subfolders of WEB-INF, and I am not able to locate any .java files.
我可以采取哪些步骤来下载该文件并使其在Eclipse上在服务器上运行?具有编辑课程的能力?
What steps can I take in order to download this and run it in eclipse on the server? With the ability to edit the classes?
我已阅读到可以在eclipse中选择一个.class文件,它将在编辑器中打开字节码,因此我想我可以轻松地将类文件转换为Java文件.但是我认为,在一般项目中执行此操作会触发错误消息,指出该类不是类路径的一部分,因此,我们需要将其放入一个可运行的Web项目中,该项目可以先在Eclipse服务器上的Tomcat服务器上运行.>
I have read that I can select a .class file in eclipse and it will open the bytecode in the editor, so I imagine I can convert the class files to java files easily enough. But doing that within a general project triggers the error message that the class is not part of the classpath, so we need to get it in a working web project that can be run on the tomcat server from within eclipse first, I think.
推荐答案
war
文件是Web应用程序的归档文件(基本上是zip).它旨在包含Web应用程序的已编译类文件和资源(属性文件,jsps,css,html,js等).它是一个包,可由Tomcat之类的应用程序服务器(或servlet容器)使用.除了通过反编译器,您将无法从已编译的 .class
文件访问源代码.
A war
file is a Web application ARchive (basically a zip). It is meant to contain a web application's compiled class files and resources (properties files, jsps, css, html, js, etc.). It a package that can be used by an application server (or servlet container) like Tomcat. Except through a Decompiler, you will not have access to the source code from the compiled .class
files.
我怀疑您可以在Eclipse的Tomcat实例上运行它.而是转到您的Tomcat安装.我的是在 C:\ apache-tomcat-7.0.22
.将 war
重命名为诸如 security.war
之类的简单名称,然后将其放置在 webapps
文件夹中. C:\ apache-tomcat-7.0.22 \ webapps \ security.war
.转到 C:\ apache-tomcat-7.0.22 \ bin
并执行 startup.bat
Windows批处理文件.该脚本设置类路径并启动包含 webapps
中所有应用程序的Java应用程序.您可以在 C:\ apache-tomcat-7.0.22 \ logs \ catalina.out
中看到启动日志(就像在Eclipse控制台中通常那样).
I doubt you can run this on Eclipse's Tomcat instances. Instead go to your Tomcat installation. Mine is at C:\apache-tomcat-7.0.22
. Rename the war
to something simple like security.war
and place it inside the webapps
folder, ie. C:\apache-tomcat-7.0.22\webapps\security.war
. Go to C:\apache-tomcat-7.0.22\bin
and execute the startup.bat
Windows batch file. This script sets up the classpath and launches a Java application containing all the applications in webapps
. You can see the startup logs in C:\apache-tomcat-7.0.22\logs\catalina.out
(as you would normally in Eclipse console).
然后您可以转到 localhost:8080/security
来运行该应用程序.将 8080
替换为您在其上配置的任何端口. security
与 war
文件的名称相同.Tomcat启动时(基于config参数),它将把 war
提取到具有相同名称的 webapps
下的软件包目录中.
You can then go to localhost:8080/security
to hit the application. Replace 8080
with whatever port you're configured on. security
is the same name as the war
file. When Tomcat starts (based on a config parameter) it will extract the war
into a package directory under webapps
with the same name.
您可以尝试配置设置.此处.
You can play around with configuration settings. Some of the important ones are here.
您可以通过运行 C:\ apache-tomcat-7.0.22 \ bin \ shutdown.bat
批处理文件脚本来关闭Tomcat.如果您在应用程序中进行了某些更改(例如,web.xml或属性文件),则必须执行此操作并重新启动.
You can shutdown Tomcat by running the C:\apache-tomcat-7.0.22\bin\shutdown.bat
Batch file script. You'll have to do this and restart if you change something in the application (ex. the web.xml or a properties file).
我认为您链接的教程的主要目的是尝试安全设置,而不是实际更改源代码.我确定还有其他在线示例可以证明Spring安全性,我只是不知道.
I think the tutorial you linked was meant more for trying security settings than actually changing the source code. I'm sure there are other samples online for Spring security, I just don't know them.
这篇关于从文件系统导入eclipse项目,然后在服务器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!