Skip to content

Conversation

@Kama-Pushka
Copy link
Owner

@Kama-Pushka Kama-Pushka commented Mar 10, 2025

Псевдосервис банковских транзакций.

  • используется DI через конструктор
  • используется DI через поле
  • используется DI через сеттеры
  • создаются и внедряются два бина разных классов, но реализующих один интерфейс
  • при создании и “разрушении” бина в лог выводится сообщение

Copy link

@nemoguigrat nemoguigrat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Укажи README с текстом ДЗ и своим ФИО, пожалуйста (либо пропиши в пояснении к pull request хотя бы ФИО)


dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.projectlombok:lombok:1.18.30")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше будет указать в compileOnly и версию можно не указывать


@Override
public void createTransaction() {
System.out.println("Create Withdraw Transaction");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты ведь здесь же в классе логирование используешь, зачем System.out?)) Всегда используй логгер, вместо System.out

import org.springframework.stereotype.Controller;

@Slf4j
@Controller

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему Controller? никаких web вызовов я не увидел


@Slf4j
@Service
@Primary

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

неудачное использование Primary, можно обойтись и без него (да и без Qualifire). Используй внедрение через имя поля (когда имя поля соответствует имени бина).

Как правило Qualifire это дурной тон, аннотация хоть и бывает полезной в определенных случаях (как и Primary) но в реальном мире ее стараются не использовать

Comment on lines +27 to +35
public void deposit() {
deposit.createTransaction();
deposit.transaction();
}

public void withdraw() {
withdraw.createTransaction();
withdraw.transaction();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Методы не используются

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants