2

Не могу активировать профиль загрузки Spring в IntelliJ IDEA.

Java 17

<spring.version>5.3.9</spring.version>

Захожу Run | Edit Configurations... и в VM options прописываю

-Dspring.profiles.active=development

И при запуске приложения из IDE вылетает такая ошибка:

Error: Could not find or load main class VM
Caused by: java.lang.ClassNotFoundException: VM

При этом вручную у меня получилось запустить с такой опцией:

java -jar main-ms-1.2-SNAPSHOT.jar --spring.profiles.active=development

Что мне еще нужно прописать в IDE, что я упустил? Почистил кеш. Перепроверил все настройки. Ни чего не помогает. Я не пойму в чем может быть проблема. При этом у других разработчиков проекта этой проблемы нет. С флагом -Dspring.profiles.active=development приложение запускается в IDEA

The bounty expires in 4 days. Answers that other users post to this question are eligible for a +50 reputation bounty. alex is looking for a canonical answer: I need to launch an application from IDEA I can't activate the Spring download profile in IntelliJ IDEA.

Java 17

IntelliJ IDEA 2021.3 Beta (Ultimate Edition)

<spring.version>5.3.9</spring.version> I'm coming in Run | Edit Configurations... and in VM options I prescribe

-Dspring.profiles.active=development And when you start the application from the IDE, the following error crashes:

Error: Could not find or load main class VM Caused by: java.lang.ClassNotFoundException: VM At the same time, I managed to launch it manually with this option:

java -jar main-ms-1.2-SNAPSHOT.jar --spring.profiles.active=development What else do I need to register in the IDE that I missed? I cleaned the cache. Rechecked all the settings. Nothing helps. I don't understand what the problem might be. At the same time, other project developers do not have this problem. With the -Spring.profiles.active=development flag, the application is launched in IDEA

profile in Pom.xml This is a shared file Pom.xml, which is at the root of the entire project on microservices.

development true development file:${project.basedir}/../../../maven ${maven.file.path}/releases ${maven.file.path}/snapshots localhost:5000 http://${docker.registry.domain} Expand snippet And this is the file pom.xml the microservice I'm trying to run. com.asvoip.ump ump-it-lib 1.1-SNAPSHOT test com.asvoip.ump ump-currencymanager-api 1.2-SNAPSHOT com.asvoip.ump ump-sqldbclient-lib 1.2-SNAPSHOT com.asvoip.ump ump-restapiserver-lib 1.1-SNAPSHOT com.asvoip.ump ump-documentation-lib 1.1-SNAPSHOT
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
  <groupId>de.codecentric</groupId>
  <artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<dependency>
  <groupId>io.springfox</groupId>
  <artifactId>springfox-boot-starter</artifactId>
</dependency>

<dependency>
  <groupId>co.elastic.logging</groupId>
  <artifactId>logback-ecs-encoder</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.dataformat</groupId>
  <artifactId>jackson-dataformat-xml</artifactId>
</dependency>
io.fabric8 docker-maven-plugin Expand snippet enter image description here enter image description here

File application.yaml

spring.config.activate.on-profile: development

Вот здесь для этого микросервиса прописал настройки, его же и пытаюсь запустить. введите сюда описание изображения

1
  • Приложите скриншот окна Edit Configurations либо весь текст самой первой строчки (до Connected to the target VM) из вывода при запуске
    – Nick
    17 ноя 2021 в 11:04

2 ответа 2

1

Ты упустил что по умолчанию IDEA грузит свой собственный JVM, и её пофигу на ENV значение что в JAVA_HOME... Когда ты грузишь с консоли то JAVA_HOME идёт от аппереционки. А исправляется достаточно просто в Project Properties добавляешь свою джаву и уже играя от неё грузишь проект.

2
  • Что значит в Project Properties добавляешь свою Java? В Properties везде указана Java 17 Я добавляю этот флаг в Run-> Edit Configuration
    – alex
    12 ноя 2021 в 9:09
  • Уточните какие именно Properties вы имеете ввиду. В IDEA в нескольких местах в настройках проекта указывается версия Java. Везде указана. Может я что-то пропустил.
    – alex
    12 ноя 2021 в 11:54
0

Установите java 8 на свой пк далее запустите через командную строку с помощью javac.если запускается то установите java в свою idea там по умолчанию стоит своя версия .

1
  • Дело в том, что проект переделан под Java 17. Он уже не запустится в Java 8. В том то и проблема, пока мы не перешли на Java 17 и Spring 5.3 с запуском не было ни каких проблем. А начиная с 5-ой версии Spring появились эти профайлы. Правда у других все прекрасно запускается. Эта проблемы только у меня.
    – alex
    17 ноя 2021 в 15:54

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.