# Gatling with Spring

**URL:** <https://community.gatling.io/t/gatling-with-spring/7362>\
**Category:** Gatling (Open-Source)\
**Created:** [December 1, 2022, 3:26am UTC](https://community.gatling.io/t/gatling-with-spring/7362 "2022-12-01T03:26:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lopodd](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@lopodd](https://community.gatling.io/u/lopodd)\
**Post date:** [December 1, 2022, 3:26am UTC](https://community.gatling.io/t/gatling-with-spring/7362/1 "2022-12-01T03:26:30Z")

</div>

Hi  
We want to use spring framework in our gatling java project, is there any example we can follow?

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [December 1, 2022, 7:10am UTC](https://community.gatling.io/t/gatling-with-spring/7362/2 "2022-12-01T07:10:37Z")

</div>

Hi,

What are you trying to achieve exactly? What kind of components can’t you instantiate directly? It’s not like you’ll need AOP for your Gatling tests.

---

<div class="post-metadata">

**Author:** ![lopodd](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@lopodd](https://community.gatling.io/u/lopodd)\
**Post date:** [December 1, 2022, 12:18pm UTC](https://community.gatling.io/t/gatling-with-spring/7362/3 "2022-12-01T12:18:12Z")

</div>

the model class are defined as spring prototype bean in other test project, we want to reuse them in gatling without rewrite all of them again.

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [December 1, 2022, 1:03pm UTC](https://community.gatling.io/t/gatling-with-spring/7362/4 "2022-12-01T13:03:11Z")

</div>

Then you have to create the ApplicationContext and pull the desired beans programmatically.

---

<div class="post-metadata">

**Author:** ![lopodd](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@lopodd](https://community.gatling.io/u/lopodd)\
**Post date:** [December 1, 2022, 1:35pm UTC](https://community.gatling.io/t/gatling-with-spring/7362/5 "2022-12-01T13:35:30Z")

</div>

Is there any examples to load spring context with Gatling Java?

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [December 1, 2022, 2:50pm UTC](https://community.gatling.io/t/gatling-with-spring/7362/6 "2022-12-01T14:50:31Z")

</div>

Nothing to do with Gatling here. You have to retrieve your beans from you `ApplicationContext` in Java code that is not aware of spring at instanciation time.

See an [article of Baeldung](https://www.baeldung.com/spring-getbean)

Cheers!

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [December 31, 2022, 2:51pm UTC](https://community.gatling.io/t/gatling-with-spring/7362/7 "2022-12-31T14:51:16Z")

</div>

Closed on December 31, 2022, 2:51pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
