wimdeblauwe / htmx-spring-boot

Spring Boot and Thymeleaf helpers for working with htmx
Apache License 2.0
521 stars 49 forks source link

Possibility to use in a Spring MVC project (without Spring Boot) #124

Open mic4126 opened 5 months ago

mic4126 commented 5 months ago

Hi, My company project currently set up the Spring project without Spring boot.

After a quick look in the repo, I find out that Spring Boot seems to only used for easier registering configuration.

So, is it possible (maybe with some PR) to work in a Spring only setup?

Thank you.

checketts commented 5 months ago

It should work in theory. You could try pulling in the dependency and excluding the Spring Boot ones

wimdeblauwe commented 5 months ago

Can you elaborate why you do not want to use Spring Boot ?

mic4126 commented 5 months ago

Because my team thinks spring boot update too ofter and company IT policy requires it team to keep update library and each update need to request user's UAT acceptance. Therefore, they remove spring boot (just use spring) from the project.

wimdeblauwe commented 5 months ago

I think the framework itself and Spring Boot have about the same amount of updates, so I don't think this is a valid concern. If you want to be up-to-date, you will have the same amount of work using Spring Boot or not. I even think you have more work without Spring Boot, since you now will have to keep track of all other dependencies (spring security, spring data, ..) that you use as well and ensure all versions are aligned. With Spring Boot, this is automatic.

mic4126 commented 5 months ago

I am only a junior programmer in the team, I can't change my team's negative opinion on Spring boot (even I think you are right.)

Also, my team is still waiting the infrasecture team to rollout jboss 8 container image, our team current still stuck at Spring 5.3.x version due to this.

ilonachan commented 2 months ago

I'm in the same situation, though my team's reason is not that we hate Spring Boot (we use it in a bunch of apps) but that moving a legacy app to a whole new foundation simply isn't worth the effort. Obviously if getting this library to work in a non-Spring-Boot context is MORE effort then that's that, but I'd be surprised.

My big question is: the main reason Spring Boot is even presupposed is because of the autoconfiguration, correct? In that case, a regular Spring MVC project would necessarily have to do that same configuration manually; what would that consist of? What do I need to define where? I believe even just the documentation of that would be worth a PR.

wimdeblauwe commented 1 month ago

I believe if you create the things that are created in https://github.com/wimdeblauwe/htmx-spring-boot/blob/main/htmx-spring-boot/src/main/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HtmxMvcAutoConfiguration.java it should probably work. But I have not tested it.

wimdeblauwe commented 1 week ago

Has anybody here successfully used it in a non Spring Boot context? If so, could you add a comment how you did it, we could then add it to the documentation (or a PR with the info is also welcome).

mic4126 commented 1 week ago

Due to time constraints, I haven't try to do it

xhaggi commented 1 week ago

I believe if you create the things that are created in HtmxMvcAutoConfiguration it should probably work. But I have not tested it.

Exactly that and the exclusion of Spring Boot in your pom.xml.

<dependency>
  <groupId>io.github.wimdeblauwe</groupId>
  <artifactId>htmx-spring-boot</artifactId>
  <version>LATEST_VERSION_HERE</version>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
    </exclusion>
  </exclusions>
</dependency>

The only class that currently depends on Spring Boot is HtmxMvcAutoConfiguration.