How to exclude maven dependencies?

You can utilize the dependency management mechanism. If you create entries in the <dependencyManagement> section of your pom for spring-security-web and spring-web with the desired 3.1.0 version set the managed version of the artifact will override those specified in the transitive dependency tree. I’m not sure if that really saves you any code, but it … Read more

Maven best practice for creating ad hoc zip artifact

Decide what classifier you will use for your zip file, for sake of argument let’s say it would be sample. In your project create file assembly/sample.xml Fill in assembly/sample.xml with something like this: <?xml version=”1.0″ encoding=”UTF-8″?> <assembly xmlns=”http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=” http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd” > <id>sample</id> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <outputDirectory>/</outputDirectory> <directory>some/directory/in/your/project</directory> </fileSet> </fileSets> <!– use … Read more

How to Solve 403 Error in Spring Boot Post Request

you have to disable csrf Protection because it is enabled by default in spring security: here you can see code that allow cors origin. import org.springframework.context.annotation.Bean; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfigurationSource; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter{ @Override protected void configure(HttpSecurity http) throws Exception{ http.cors().and().csrf().disable(); } @Bean CorsConfigurationSource … Read more

Make maven’s surefire show stacktrace in console

A related problem that I found is that surefire in recent versions apparently sets trimStackTrace to true by default (rendering most stack trace in failed tests useless), which is quite inconvenient. Setting -DtrimStackTrace=false or defining <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <trimStackTrace>false</trimStackTrace> </configuration> </plugin> solved this.

RESTEasy: Could not find writer for content-type application/json type

If you plan to use newer versions of resteasy that implement JAX-RS 2.0, the following dependencies should solve your problem: <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>3.0.5.Final</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>jaxrs-api</artifactId> <version>3.0.5.Final</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxb-provider</artifactId> <version>3.0.5.Final</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jackson2-provider</artifactId> <version>3.0.5.Final</version> </dependency>