import source code (meant for eclipse spring STS) into intellij

折月煮酒 提交于 2019-12-06 15:47:42

The project you linked to looks like a standard maven Spring Boot application.

  1. Download and unzip the project
  2. Start IntelliJ
  3. At the Welcome screen, select "Open" (instead of import)
  4. Navigate to the project folder/directory and click "Open"

That's it! IntelliJ will detect the maven structure and will setup the project appropriately (downloading dependencies, etc., which might take a couple of minutes).

To start the application, you can click on the "maven" panel on the right side of the screen, find the spring-boot plugin, and select spring-boot:run.

ps. it looks like this particular project was written for JDK 8. If you're using JDK 9 or above then you may need to make changes to make the project run.

I've downloaded and run the Spring Boot application from your link. It starts and passes the tests.

Short answer

Looks that your problem is what class you're running.

  • Run \springmvc-ws\src\test\java\com\appsdeveloperblog\app package as JUnit to run the tests.
  • Run com.appsdeveloperblog.app.ws.MobileAppWsApplication class as Spring Boot application to run the application.

Long answer

What I've done to run the application and the tests:

  • Clone the project from github: run git clone https://github.com/simplyi/springmvc-ws.git in the console. The project will be cloned into springmvc-ws sub-directory of from where you executed git clone.
  • In IDEA, select File -> Open (from keyboard: Alt + F, O), select the cloned springmvc-ws folder.
  • Select OK. If required, answer to open it in current or new window.
  • Wait for the project to be imported (no running operations displayed in the bottom status bar).

To run the application

  • Open class MobileAppWsApplication (you can type it in Ctrl + N as a quick "Go to class" shortcut).
  • Press Shift + Alt + F10.
  • Select execution with Spring Boot icon and select Run. See the screenshot below.

  • In Run tool window at the bottom, you'll see that the application has started on localhost:8080 under the context-path /mobile-app-ws:

2019-06-21 15:42:51.585  INFO 31920 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path '/mobile-app-ws'
2019-06-21 15:42:51.588  INFO 31920 --- [           main] c.a.app.ws.MobileAppWsApplication        : Started MobileAppWsApplication in 8.688 seconds (JVM running for 10.143)
  • In the Endpoints tab of this Run tool window, you can see the web-service endpoints of the started application.

To run the tests

  • Stop the application if it is running (Red Stop button in Run tool window), to not have the clashing ports.
  • In Project window (Alt + 1), select the directory \springmvc-ws\src\test\java\com\appsdeveloperblog and press Shift + Alt + F10 on it.
  • Select the point with JUnit (arrows) icon on it and then select Run point. See the screenshot below.

  • Run tool window will activate. Wait for the tests to pass. You can expand the directory to see the tests results.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!