Spring’s JdbcTemplate and Transactions

Yes, JdbcTemplate is not a substitute for transaction management. You still benefit from database transactions, so userService.updateUser will operate in a database transaction, but if accountService.updateXXX fails, userService.updateUser will not rollback. If you don’t want to use AOP, you can use TransactionTemplate instead. See programmatic transaction management in the Spring Reference Documentation. One pattern I’ve … Read more

MapStruct – @Mapper annotation don’t create bean

I resolved the error by doing mvn clean install Also add this to your pom <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> <configuration> <source>1.8</source> <target>1.8</target> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> </path> <path> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>${org.mapstruct.version}</version> </path> </annotationProcessorPaths> <compilerArgs> <compilerArg> -Amapstruct.defaultComponentModel=spring </compilerArg> </compilerArgs> </configuration> </plugin>

Multiple Spring @Scheduled tasks simultaneously

You should use TaskScheduler for your purpose @Bean public ThreadPoolTaskScheduler threadPoolTaskScheduler() { ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); threadPoolTaskScheduler.setPoolSize(THREADS_COUNT); return threadPoolTaskScheduler; } Where THREADS_COUNT – total count of tasks which should be executed in parallel. If I understand you correctly, you have only 2 jobs, so you need 2 threads

Difference between Spring and Spring Boot

In short Spring Boot reduces the need to write a lot of configuration and boilerplate code. It has an opinionated view on Spring Platform and third-party libraries so you can get started with minimum effort. Easy to create standalone applications with embedded Tomcat/Jetty/Undertow. Provides metrics, health checks, and externalized configuration. You can read more here … Read more

why does transaction roll back on RuntimeException but not SQLException

This is defined behaviour. From the docs: Any RuntimeException triggers rollback, and any checked Exception does not. This is common behaviour across all Spring transaction APIs. By default, if a RuntimeException is thrown from within the transactional code, the transaction will be rolled back. If a checked exception (i.e. not a RuntimeException) is thrown, then … Read more

Where and how to deploy a Java Spring Boot application for free? [closed]

I too have used GCP to host a Spring-Boot service. I followed this article almost religiously provided by Spring Boot(https://www.baeldung.com/spring-boot-google-app-engine) as well as this github read me that includes extra information about preparing your service to be hosted onto GCP (https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/springboot-appengine-standard) The main idea is that you will need to create a CLOUD SQL instance … Read more

Is there a uuid validator annotation?

yes, build it by yourself @Target(ElementType.FIELD) @Constraint(validatedBy={}) @Retention(RUNTIME) @Pattern(regexp=”^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$”) public @interface UUID { String message() default “{invalid.uuid}”; Class<?>[] groups() default {}; Class<? extends Payload>[] payload() default {}; }

Spring Boot can’t autowire @ConfigurationProperties

This is expected as @ConfigurationProperties does not make a class a Spring Component. Mark the class with @Component and it should work. Note that a class can only be injected if it is a Component. Edit: From Spring 2.2+ (Reference) @ConfigurationProperties scanning Classes annotated with @ConfigurationProperties can now be found via classpath scanning as an … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)