Alle FachrichtungenTechnologie · Vorstellungsgespräch

Spring

Spring-Gespräche verbinden Framework-Theorie mit Alltagsentscheidungen. Erklären Sie, was das Framework für Sie übernimmt und was Sie ohne es tun würden.

Wörter → Wendungen → Sätze → Sprechen

SpeakRole ausprobieren ↗
VorstellungsgesprächSpring
V

How does dependency injection work in Spring?

0:18
Interviewfrage

Spring

Interviewer für Spring-Stellen wollen hören, dass Sie verstehen, was hinter den Annotationen passiert. Zu sagen, dass @Autowired „einfach funktioniert“, reicht nicht. Entscheidend ist zu erklären, wie der Container Beans erzeugt und miteinander verbindet.

Ein guter Aufbau für mündliche Antworten: welches Problem das Feature löst, wie es im Framework funktioniert und eine Stolperfalle aus einem echten Projekt. Stolperfallen lassen eine Antwort nach Erfahrung klingen statt nach Auswendiggelerntem.

  • ✓Wörter → Wendungen → Sätze → Sprechen
  • ✓Sinn der Antwort
  • ✓Sprache

Häufige Fragen und Beispielantworten

How does dependency injection work in Spring?

Wie funktioniert Dependency Injection in Spring?

Was der Interviewer hören möchte. Die Rolle des Containers, Konstruktor-Injection und warum sie das Testen erleichtert.

Beispielantwort auf Englisch zum lauten Üben

In Spring, I do not create my dependencies with new. I declare what a class needs, usually in the constructor, and the container creates the objects, which we call beans, and passes them in. At startup Spring scans the classes, builds a graph of beans and connects them. I prefer constructor injection, because dependencies are explicit and can be final, and in a unit test I can pass a mock directly without starting Spring. Field injection hides dependencies and makes classes harder to test.

What are bean scopes in Spring?

Was sind Bean Scopes in Spring?

Was der Interviewer hören möchte. Singleton als Standard und warum Zustand innerhalb von Singletons gefährlich ist.

Beispielantwort auf Englisch zum lauten Üben

The default scope is singleton: Spring creates one instance per application context and shares it. Prototype creates a new instance every time the bean is requested. In web applications there are also request and session scopes. The most important thing to remember is that singleton beans are shared between threads, so they must not keep mutable request-specific state in fields. If I need per-request data, I pass it as method arguments or use a request-scoped bean.

How does @Transactional work, and what are its pitfalls?

Wie funktioniert @Transactional, und welche Stolperfallen gibt es dabei?

Was der Interviewer hören möchte. Der Proxy-Mechanismus, das Problem des Aufrufs innerhalb derselben Klasse (Self-Invocation) und die Rollback-Regeln.

Beispielantwort auf Englisch zum lauten Üben

Spring wraps the bean in a proxy. When a method with @Transactional is called from outside, the proxy opens a transaction, calls the real method, and commits or rolls back. One pitfall is self-invocation: if a method calls another transactional method in the same class, the call does not go through the proxy, so the annotation is ignored. Another is that by default Spring rolls back only on unchecked exceptions, not on checked ones, unless I set rollbackFor. I also keep transactions short and avoid remote calls inside them.

What does Spring Boot auto-configuration do?

Was macht die Auto-Konfiguration von Spring Boot?

Was der Interviewer hören möchte. Bedingte Konfiguration und wie man sie überschreibt.

Beispielantwort auf Englisch zum lauten Üben

Spring Boot looks at the libraries on the classpath and the properties I set, and configures sensible defaults for me. For example, if it sees a database driver and a connection URL, it creates a DataSource. Each auto-configuration class is guarded by conditions, like "only if this class is present" or "only if I did not define my own bean". That last condition is important, because it means I can always override the default by defining my own bean. When something behaves strangely, I enable the conditions report to see what was applied and why.

How do you handle exceptions in a Spring REST API?

Wie behandeln Sie Exceptions in einer Spring-REST-API?

Was der Interviewer hören möchte. Zentrale Behandlung und ein einheitliches Fehlerformat.

Beispielantwort auf Englisch zum lauten Üben

I use a class with @RestControllerAdvice and methods annotated with @ExceptionHandler. This way controllers stay clean, and every error is converted to the same JSON format: a status code, a short error code and a message that is safe to show. I map business exceptions to the right HTTP status, for example 404 for a missing resource and 409 for a conflict. I never return stack traces to clients. I log the details with a correlation ID, so support can find the full error in the logs.

So sprechen Sie die wichtigsten Begriffe aus

bean
bien
annotation
än-e-TEJ-schen
dependency
di-PEN-den-ssi
injection
in-DSCHEK-schen
proxy
PROK-ssi
singleton
SING-gl-ten

Nützliche Formulierungen für die Antwort

  • Under the hood, Spring creates a proxy that…Unter der Haube erzeugt Spring einen Proxy, der…
  • The default behaviour is…, but I can change it by…Das Standardverhalten ist…, aber ich kann es ändern, indem ich…
  • One pitfall I ran into was…Eine Stolperfalle, auf die ich gestoßen bin, war…
  • In a unit test, I would replace this with a mock.In einem Unit-Test würde ich das durch einen Mock ersetzen.
  • That depends on whether…Das hängt davon ab, ob…
  • I would check the documentation for the exact rule, but the idea is…Die genaue Regel würde ich in der Dokumentation nachschlagen, aber die Idee ist…

Typische Fehler

  • Nur Annotationen aufzählen. Erklären Sie, was jede davon das Framework tun lässt.
  • Spring „Magie“ nennen. Das klingt, als würden Sie es nicht verstehen. Verwenden Sie Wörter wie „Container“ und „Proxy“, um zu beschreiben, was passiert.
  • Das Testen nicht erwähnen. Interviewer hören gern, wie sich eine Entwurfsentscheidung auf Unit- und Integrationstests auswirkt.
  • Spring und Spring Boot verwechseln. Spring ist das Framework; Spring Boot ergänzt Auto-Konfiguration, Starter und einen eingebetteten Server.

Häufig gestellte Fragen

Soll ich Spring oder Spring Boot lernen?

Beides, in dieser Reihenfolge: zuerst die Kernideen von Spring (Container, Beans, Proxys), dann das, was Spring Boot obendrauf bringt. Interviewer fragen oft mit Boot-Beispielen nach den Kernideen.

Muss ich Spring Security kennen?

Für Backend-Stellen in den meisten Unternehmen ja, auf grundlegendem Niveau: Authentifizierung im Unterschied zur Autorisierung, die Filterkette und wie Sie einen Endpunkt schützen. Sagen Sie ehrlich, was Sie eingesetzt haben.

Wie beschreibe ich meine Spring-Erfahrung?

Nennen Sie die Version, die verwendeten Module (Web, Data, Security) und ein Problem, das Sie gelöst haben. Ein konkretes Problem überzeugt mehr als eine Liste von Annotationen.

Eine Antwort zu lesen ist nicht dasselbe, wie sie auszusprechen. Üben Sie jede Frage laut und vergleichen Sie danach Inhalt und Sprache Ihrer eigenen Antwort.

SpeakRole ausprobieren ↗

Weitere Themen in diesem Bereich