简体   繁体   English

从Eclipse运行Java Spring应用程序

[英]Run Java Spring application from eclipse

I'm working on a project at work that runs on the spring framework and requires a connection to an oracle database at all times. 我正在研究一个在spring框架上运行的项目,该项目始终需要连接到oracle数据库。 When I want to test a new method I have to stop my server, rebuild, start the server, then launch my application. 当我想测试一种新方法时,我必须停止服务器,重新构建,启动服务器,然后启动我的应用程序。

My question is is there any way to run my application without having to launch it every time? 我的问题是有什么方法可以运行应用程序而不必每次都启动它吗? I'm okay with having to restart the server but I'm trying to eliminate launching the application every time. 我可以重新启动服务器,但我想避免每次都启动应用程序。

Cheers. 干杯。

What you seek are integration tests. 您寻求的是集成测试。 You need to break your application into individual pieces and test their functionality against the oracle database bit by bit. 您需要将应用程序分成多个部分,并针对oracle数据库一点一点地测试其功能。 These little pieces can be tested by certain testing technologies such as the popular JUnit. 这些小片段可以通过某些测试技术(例如流行的JUnit)进行测试。

All the pieces that you need should only depend on the data source and whatever other collaborating beans that are needed. 您需要的所有片段都仅取决于数据源以及所需的任何其他协作bean。 Break your bean definitions apart such that they are small and only depend on very few beans, tracking back to the data source bean. 将您的bean定义拆开,使其很小,仅依赖很少的bean,然后回溯到数据源bean。 You can then use JUnit (or whatever testing technology you'd like) and Spring's testing annotations to make small application contexts 然后,您可以使用JUnit(或您想要的任何测试技术)和Spring的测试注释来创建小型应用程序上下文

See this section of the Spring reference manual for more information: 有关更多信息,请参见Spring参考手册的这一部分:

http://static.springsource.org/spring/docs/current/spring-framework-reference/html/testing.html http://static.springsource.org/spring/docs/current/spring-framework-reference/html/testing.html

When you have tests, you don't actually run the application - you run a part of it to verify its behavior individually. 在进行测试时,您实际上并没有运行该应用程序,而是运行了该应用程序的一部分来单独验证其行为。 You can then add tests that test the pieces together, and eventually your confidence in the application will rise. 然后,您可以添加测试以对各个部分进行测试,最终您对应用程序的信心将会增强。

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

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