Last active
April 20, 2025 15:13
-
-
Save unclebean/559ca2a36b8196f7cc77e012724cd3e5 to your computer and use it in GitHub Desktop.
multi modules maven project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<groupId>com.example</groupId> | |
<artifactId>my-app-parent</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
</parent> | |
<artifactId>auth</artifactId> | |
<packaging>jar</packaging> | |
<dependencies> | |
<!-- depends on common --> | |
<dependency> | |
<groupId>com.example</groupId> | |
<artifactId>common</artifactId> | |
</dependency> | |
<!-- Spring Security --> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-security</artifactId> | |
</dependency> | |
</dependencies> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<groupId>com.example</groupId> | |
<artifactId>my-app-parent</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
</parent> | |
<artifactId>search-app</artifactId> | |
<packaging>jar</packaging> | |
<dependencies> | |
<!-- Spring Boot starters --> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-web</artifactId> | |
</dependency> | |
<!-- modules --> | |
<dependency> | |
<groupId>com.example</groupId> | |
<artifactId>common</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>com.example</groupId> | |
<artifactId>auth</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>com.example</groupId> | |
<artifactId>search</artifactId> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-maven-plugin</artifactId> | |
<version>${spring.boot.version}</version> | |
<executions> | |
<execution> | |
<goals> | |
<goal>repackage</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.app; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
@SpringBootApplication | |
public class Application { | |
public static void main(String[] args) { | |
SpringApplication.run(Application.class, args); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<parent> | |
<groupId>com.example</groupId> | |
<artifactId>my-app-parent</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
</parent> | |
<modelVersion>4.0.0</modelVersion> | |
<artifactId>common</artifactId> | |
<packaging>jar</packaging> | |
<!-- Common utilities and shared DTOs --> | |
<dependencies> | |
<dependency> | |
<groupId>org.projectlombok</groupId> | |
<artifactId>lombok</artifactId> | |
<optional>true</optional> | |
</dependency> | |
</dependencies> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.example</groupId> | |
<artifactId>my-app-parent</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
<packaging>pom</packaging> | |
<modules> | |
<module>search-app</module> | |
<module>common</module> | |
<module>auth</module> | |
<module>search</module> | |
</modules> | |
<properties> | |
<java.version>17</java.version> | |
<spring.boot.version>3.4.4</spring.boot.version> | |
</properties> | |
<dependencyManagement> | |
<dependencies> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-dependencies</artifactId> | |
<version>${spring.boot.version}</version> | |
<type>pom</type> | |
<scope>import</scope> | |
</dependency> | |
<!-- Internal module versions --> | |
<dependency> | |
<groupId>com.example</groupId> | |
<artifactId>common</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
</dependency> | |
<dependency> | |
<groupId>com.example</groupId> | |
<artifactId>auth</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
</dependency> | |
<dependency> | |
<groupId>com.example</groupId> | |
<artifactId>search</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
</dependency> | |
</dependencies> | |
</dependencyManagement> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.app; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.*; | |
@RestController | |
@RequestMapping("/{pid}/search") | |
public class SearchController { | |
@GetMapping | |
public String testSearch(@PathVariable("pid") String pid) { | |
return pid; | |
} | |
@PostMapping | |
public ResponseEntity<?> handleSearch( | |
@PathVariable("pid") String pid, | |
@RequestParam("isClientData") boolean isClientData, | |
@RequestBody String requestBody) { | |
if (isClientData) { | |
return handleClientDataSearch(pid, requestBody); | |
} else { | |
return handleGenericSearch(pid, requestBody); | |
} | |
} | |
private ResponseEntity<?> handleClientDataSearch(String pid, String requestBody) { | |
// logic for client data search | |
return ResponseEntity.ok("Client data search executed for PID: " + pid); | |
} | |
private ResponseEntity<?> handleGenericSearch(String pid, String requestBody) { | |
// logic for generic search | |
return ResponseEntity.ok("Generic search executed for PID: " + pid); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.app; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; | |
import org.springframework.security.web.SecurityFilterChain; | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
@Configuration | |
public class SecurityConfig { | |
@Bean | |
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | |
http | |
.csrf(csrf -> csrf.disable()) | |
.formLogin(form -> form.disable()) | |
.httpBasic(basic -> basic.disable()) | |
.authorizeHttpRequests(auth -> auth | |
.requestMatchers("/*/search", "/health", "/swagger-ui/**", "/v3/api-docs/**").permitAll() | |
.anyRequest().authenticated() | |
); | |
return http.build(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<groupId>com.example</groupId> | |
<artifactId>my-app-parent</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
</parent> | |
<artifactId>search</artifactId> | |
<packaging>jar</packaging> | |
<dependencies> | |
<!-- depends on common --> | |
<dependency> | |
<groupId>com.example</groupId> | |
<artifactId>common</artifactId> | |
</dependency> | |
</dependencies> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment