Spring Data JPA – Why are changes to a returned Entity automatically persisted?

That’s a fundamental principle of JPA. You work with attached (managed) entities, and every modification made on these managed entities is automatically made persistent. If you don’t want your changes to be persistent, then don’t make changes, or rollback the transaction. Working on detached entities would be a nightmare, because it would prevent lazy-loading all … Read more

How to configure rolling file appender within Spring Boot’s application.yml

The default file appender is size based (10MB). In your logback.xml just configure a TimeBasedRollingPolicy as described here I.e. something like: <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <include resource=”org/springframework/boot/logging/logback/base.xml”/> <appender name=”ROLLIN” class=”ch.qos.logback.core.rolling.RollingFileAppender”> <file>${LOG_FILE}</file> <rollingPolicy class=”ch.qos.logback.core.rolling.TimeBasedRollingPolicy”> <!– daily rollover –> <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern> </rollingPolicy> </appender> <root level=”INFO”> <appender-ref ref=”ROLLIN” /> </root> <logger name=”org.springframework.web” level=”INFO”/> </configuration>

Spring vs Java EE 7 [closed]

I will share little bit of what I know about using Spring. You are right by saying that Java EE 7 has all the technologies to help solve the problems. Well Spring just enhances these capabilities and makes life more easier for a developer. As an example when you use Spring MVC framework you can … Read more

Get spring application environment in thymeleaf

You can do the following if you only have one profile active at a time. <div th:if=”${@environment.getActiveProfiles()[0] == ‘production’}”> This is the production profile – do whatever you want in here </div> The code above is based on the fact that the Thymeleaf’s Spring dialect lets you access beans using the @ symbol. And of … Read more

Spring Boot + Spring-Loaded (IntelliJ, Gradle)

You need to configure the project as stated in the documentation: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-reload-springloaded-gradle-and-intellij-idea After that, you must configure your IDE to output the compiled classes in build/classes/main (with Idea plugin, you can configure the outputDir as specified in the above link, and then invoke gradle idea to have it done). Then, if you launch the task … Read more

No adapter for handler exception

By default the spring mvc defines 3 different request handler adapters, they are org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter So you need not have to define them in your context file, but if you define at least one handler adapter in your context files, spring will not create the default adapters. In your configuraion you are using <mvc:annotation-driven … Read more