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

一个人想着一个人 提交于 2019-12-23 00:35:49

问题


How to import and run spring mvc github source code meant for Eclipse Spring STS into IntelliJ?

What I did:

  1. downloaded working spring mvc project source code zip file https://github.com/simplyi/springmvc-ws?fbclid=IwAR2xKg6Oh0YHLuVJ2YEh2vt6cr1u3-4E4IzKnPMDJVc6nvI-BN6pRaPMKHQ

  2. 'import' upon starting Intellij

  3. don't know what configurations to pick so got a lot of errors. SO, followed this https://www.lagomframework.com/documentation/1.5.x/java/IntellijMaven.html?fbclid=IwAR3JaAw6dF2jX9k4fxxKg37j8mpNI2dNTEqupVULzLrk83G_wEtN4beNJsI

  4. BUT got error: ERROR] No plugin found for prefix 'lagom' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories

So, I'm giving up on this tutorial in above link.

Here is gyazo screenshot of Intellij terminal errors: https://gyazo.com/7f83cca2baeff6ca383885f814325477

This gyazo screenshot shows external libraries: https://gyazo.com/6e2898508b64061ebf726fc46881b0ef

How to import this source code into Intellij & run/test the webapp?

Thank you!


回答1:


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.




回答2:


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.


来源:https://stackoverflow.com/questions/56696454/import-source-code-meant-for-eclipse-spring-sts-into-intellij

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!