1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

MkkAdvent Calendar 2022

Day 14

JavaをMacで開発してたときのメモ

Last updated at Posted at 2022-12-14

macOSでのJDKのインストール

STS(Spring Tool Suite)のポート番号変更

application.propertiesを編集

スクリーンショット_2022-04-01_20.53.29.jpg
スクリーンショット_2022-04-01_20.54.06.png

DemoApplicationTests.javaの

エラー

※pom.xmlを修正しても、src/test/javaDemoApplicationTests.javaが、エラーになった場合。

DemoApplicationTests.javaのimportを以下に変更

DemoApplicationTests.java
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;

The requested profile "pom.xml" could not be activated because it does not exist.の解消

maven install

[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.548 s[INFO] Finished at: 2017-12-31T02:08:08+09:00[INFO] Final Memory: 11M/243M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
  1. プロジェクト名を右クリック→プロパティーMaven
  2. アクティブmavenプロファイルに入力されているpom.xmlを削除して適用して閉じる
  3. もう一度maven install
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ demo ---
[INFO] Installing /Applications/SpringToolSuite4.app/workspace/demo/target/demo-0.0.1-SNAPSHOT.jar to /Users/mkk/.m2/repository/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar
[INFO] Installing /Applications/SpringToolSuite4.app/workspace/demo/pom.xml to /Users/mkk/.m2/repository/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.996 s[INFO] Finished at: 2022-04-01T21:09:15+09:00[INFO] ------------------------------------------------------------------------

参考記事

jarファイルの実行

  1. maven installで作成されたtargetフォルダを開いてjarファイルをコピー

スクリーンショット_2022-04-01_21.35.24.jpg

  1. 適当なフォルダの中にペーストして名前を変えておく(hello.jarにした)
  2. ターミナルで2のフォルダに移動してjava -jar hello.jarを実行
% java -jar hello.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.6)

2022-04-01 21:24:17.222  INFO 4985 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 1.63 seconds (JVM running for 2.155)
2022-04-01 21:24:41.606  INFO 4985 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-04-01 21:24:41.607  INFO 4985 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-04-01 21:24:41.608  INFO 4985 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms

jarファイルがあればTomcatがなくても(Webサーバーがなくても)Webアプリが起動できる

※Javaがインストールされていることが前提

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?