Skip to content

Openrewrite plugin to refactor Spring MVC PathVariable and RequestParam annotations

License

Notifications You must be signed in to change notification settings

omidp/spring-mvc-migrator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

What is MVC migrator

This project helps you to refactor your spring MVC PathVariable and RequestParam and add explicit names to those annotations.

for example :

From

@GetMapping("/{userId}/comments/{id}")
public ResponseEntity<String> getUser(@PathVariable(required=false) Long userId, @PathVariable Long id) {
	 System.out.println(id);
}

To

@GetMapping("/{userId}/comments/{id}")
public ResponseEntity<String> getUser(@PathVariable(required=false, value="userId") Long userId, @PathVariable("id") Long id) {
	System.out.println(id);
}

How to build

  • Clone and build the project
mvn clean install

How to use

  • Add the open rewrite plugin to your maven pom file
<plugin>
   <groupId>org.openrewrite.maven</groupId>
   <artifactId>rewrite-maven-plugin</artifactId>
   <version>5.15.4</version>
   <configuration>
      <activeRecipes>
         <recipe>com.omidp.app.ExplicitWebAnnotationNames</recipe>
      </activeRecipes>
   </configuration>
   <dependencies>
      <!-- This module isn't packaged with OpenRewrite -->
      <dependency>
         <groupId>com.omidp.app</groupId>
         <artifactId>mvc-migrator</artifactId>
         <version>1.0-SNAPSHOT</version>
      </dependency>
   </dependencies>
</plugin>
  • Execute the plugin
mvn rewrite:run

Or depends on your POM configuration

mvn org.openrewrite.maven:rewrite-maven-plugin:run

About

Openrewrite plugin to refactor Spring MVC PathVariable and RequestParam annotations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages