LoginSignup
1
2

More than 3 years have passed since last update.

Eclipseで作成した既存のSpringBootプロジェクトをVSCodeで実行

Last updated at Posted at 2021-04-14

単にフォルダの読み込みだけではだめだったので書き留めます

環境

Eclipse 2020-12
Spring Boot 2.4.0
java 8
バージョン管理 Git

やったこと

VSCodeでEclipseで開発したSpringBootのWorkSpace(作業フォルダ)を読み込んだ。
んでRun → Start Debugging

読み込んだときに自動的にWorkSpaceに.vscodeのフォルダが作成され、その中にlaunch.jsonが作成されます。

どうやらそれがVSCodeの実行に必要みたい。

lauch.json(初期状態)

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-chrome", // ここを変えないといけない
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8080", \\ ここは変えてあるかもしれません
            "webRoot": "${workspaceFolder}"
        }
    ]
}


とりあえず入れたExtensionsたち

なんかjavaとかSpringで検索して出てきたPackになっているやつでいれました。

image.png

結果

Chromeが立ち上がるけどだめ

launch.jsonを修正

launch.json(修正版)
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    // java.homeも設定するような記事があったので、インストールしていたものを読み込むようにしました
    "java.home": "C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.9.101-hotspot",
    "configurations": [
        {
            "type": "java", // 結局ここを"java"にすれば良いだけ
            "request": "launch",
            "name": "Launch Chrome against localhost",
            // 他にもかいてあったけど、消しても動きました
        }
    ]
}


他にやったことは?

configをいじった
image.png

Settings - MOSRepository - Visual Studio Code 2021-04-14 22.13.49.png

settings.json
{
    "files.exclude": {
        "**/.classpath": true,
        "**/.project": true,
        "**/.settings": true,
        "**/.factorypath": true
    },
    "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m -javaagent:\"c:\\Users\\yumasky\\.vscode\\extensions\\gabrielbb.vscode-lombok-1.0.1\\server\\lombok.jar\"",
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "spring-boot.ls.java.home": "", // ここにもJDKのパスを入力してたけど、消しても動いた!
    "cloudfoundry-manifest.ls.java.home": ""
}

まだちゃんとわかっているわけではないです。。。

とりあえず調べてた記事の中では基本的にVSCodeで新しくSpringBootのプロジェクトを作成の流れが多く、最初はEclipseで、途中からVSCodeでみたいな乗り換えの方法はなかなか見つかりませんでした。

そういう方の参考になればと思います。

また、補足説明できる方、ぜひコメントでよろしくお願いいたしますm(__)m

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2