Skip to content

Commit

Permalink
updated to java 19 and Spring 3.0.3, all working on localhost, winner…
Browse files Browse the repository at this point in the history
… is webflux
  • Loading branch information
armena committed Mar 13, 2023
1 parent 9473f17 commit 472e56a
Show file tree
Hide file tree
Showing 28 changed files with 328 additions and 316 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/reactivetomcat/target/
/webflux/target/
/undertow/target/
/tomcat/target/
18 changes: 18 additions & 0 deletions reactivetomcat/nb-configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.jdkPlatform>Temurin_19.0.2_7</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>
8 changes: 4 additions & 4 deletions reactivetomcat/nbactions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<goal>spring-boot:run</goal>
</goals>
<properties>
<spring-boot.run.jvmArguments>-noverify -XX:TieredStopAtLevel=1 </spring-boot.run.jvmArguments>
<spring-boot.run.mainClass>io.project.app.sp34.Sp34Application</spring-boot.run.mainClass>
<run.jvmArguments>-noverify -XX:TieredStopAtLevel=1 </run.jvmArguments>
<run.mainClass>io.project.app.sp34.Sp34Application</run.mainClass>
<Env.SPRING_OUTPUT_ANSI_ENABLED>always</Env.SPRING_OUTPUT_ANSI_ENABLED>
</properties>
</action>
Expand All @@ -23,8 +23,8 @@
<goal>spring-boot:run</goal>
</goals>
<properties>
<spring-boot.run.jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1 </spring-boot.run.jvmArguments>
<spring-boot.run.mainClass>io.project.app.sp34.Sp34Application</spring-boot.run.mainClass>
<run.jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1 </run.jvmArguments>
<run.mainClass>io.project.app.sp34.Sp34Application</run.mainClass>
<Env.SPRING_OUTPUT_ANSI_ENABLED>always</Env.SPRING_OUTPUT_ANSI_ENABLED>
<jpda.listen>true</jpda.listen>
</properties>
Expand Down
32 changes: 10 additions & 22 deletions reactivetomcat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<version>3.0.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.project.app</groupId>
Expand All @@ -15,39 +15,27 @@
<description>reactivetomcat</description>

<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR3</spring-cloud.version>
<java.version>19</java.version>
<spring-cloud.version>2022.0.1</spring-cloud.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
<version>0.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webflux</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down
40 changes: 40 additions & 0 deletions reactivetomcat/src/main/java/io/project/app/CorsConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.project.sp;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.cors.reactive.CorsUtils;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;

/**
*
* @author armen
*/
@Configuration
public class CorsConfiguration {

private static final String ALLOWED_HEADERS = "*";
private static final String ALLOWED_METHODS = "GET, PUT, POST, DELETE, OPTIONS, PATCH";
private static final String ALLOWED_ORIGIN = "*";
private static final String MAX_AGE = "7200";

@Bean
public WebFilter corsFilter() {
return (ServerWebExchange ctx, WebFilterChain chain) -> {
ServerHttpRequest request = ctx.getRequest();
if (CorsUtils.isCorsRequest(request)) {
ServerHttpResponse response = ctx.getResponse();
HttpHeaders headers = response.getHeaders();
headers.add("Access-Control-Allow-Origin", ALLOWED_ORIGIN);
headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS);
headers.add("Access-Control-Max-Age", MAX_AGE);
headers.add("Access-Control-Allow-Headers", ALLOWED_HEADERS);
}
return chain.filter(ctx);
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.project.sp;

import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenApiConfiguration {

@Bean
public GroupedOpenApi publicApi() {
return GroupedOpenApi.builder()
.group("publicapi")
.packagesToScan("io.project")
.pathsToMatch("/api/**")
.build();
}

}
48 changes: 0 additions & 48 deletions reactivetomcat/src/main/java/io/project/app/SwaggerConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class KillerService {
@Autowired
private RestTemplate restTemplate;

private List<String> targetList = Arrays.asList("http://localhost:2023/actuator/shutdown", "http://venera:2077/actuator/shutdown",
private final List<String> targetList = Arrays.asList("http://localhost:2023/actuator/shutdown", "http://venera:2077/actuator/shutdown",
"http://localhost:2021/actuator/shutdown", "http://localhost:2022/actuator/shutdown", "http://mars:8585858585/actuator/shutdown");

@Scheduled(fixedDelay = 8000)
Expand All @@ -44,7 +44,6 @@ public void shoot() {

if (!kill.isSuccess()) {
log.info("FAIL: Could not kill microservice with following address: " + url);
//log.info(kill.toString());
}

}
Expand Down
18 changes: 18 additions & 0 deletions tomcat/nb-configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.jdkPlatform>Temurin_19.0.2_7</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>
8 changes: 4 additions & 4 deletions tomcat/nbactions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<goal>spring-boot:run</goal>
</goals>
<properties>
<spring-boot.run.jvmArguments>-noverify -XX:TieredStopAtLevel=1 </spring-boot.run.jvmArguments>
<spring-boot.run.mainClass>io.project.app.sp34.Sp34Application</spring-boot.run.mainClass>
<run.jvmArguments>-noverify -XX:TieredStopAtLevel=1 </run.jvmArguments>
<run.mainClass>io.project.app.sp34.Sp34Application</run.mainClass>
<Env.SPRING_OUTPUT_ANSI_ENABLED>always</Env.SPRING_OUTPUT_ANSI_ENABLED>
</properties>
</action>
Expand All @@ -23,8 +23,8 @@
<goal>spring-boot:run</goal>
</goals>
<properties>
<spring-boot.run.jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1 </spring-boot.run.jvmArguments>
<spring-boot.run.mainClass>io.project.app.sp34.Sp34Application</spring-boot.run.mainClass>
<run.jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1 </run.jvmArguments>
<run.mainClass>io.project.app.sp34.Sp34Application</run.mainClass>
<Env.SPRING_OUTPUT_ANSI_ENABLED>always</Env.SPRING_OUTPUT_ANSI_ENABLED>
<jpda.listen>true</jpda.listen>
</properties>
Expand Down
34 changes: 11 additions & 23 deletions tomcat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<version>3.0.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.project.app</groupId>
Expand All @@ -15,44 +15,33 @@
<description>tomcat</description>

<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR3</spring-cloud.version>
<java.version>19</java.version>
<spring-cloud.version>2022.0.1</spring-cloud.version>
</properties>

<dependencies>
<dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
<version>0.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand All @@ -68,8 +57,7 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>

</dependency>
</dependencies>

<dependencyManagement>
Expand Down
20 changes: 20 additions & 0 deletions tomcat/src/main/java/io/project/app/OpenApiConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.project.app;

import org.springdoc.core.models.GroupedOpenApi;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenApiConfiguration {

@Bean
public GroupedOpenApi publicApi() {
return GroupedOpenApi.builder()
.group("publicapi")
.packagesToScan("io.project")
.pathsToMatch("/api/**")
.build();
}

}
18 changes: 18 additions & 0 deletions tomcat/src/main/java/io/project/app/RegularTomcatApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@ComponentScan("io.project.app")
Expand All @@ -25,4 +28,19 @@ public static void main(String[] args) {
public RestTemplate restTemplate() {
return new RestTemplate();
}

@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry
.addMapping("/**")
.allowedMethods(CorsConfiguration.ALL)
.allowedHeaders(CorsConfiguration.ALL)
.allowedOriginPatterns(CorsConfiguration.ALL);
}
};
}

}
Loading

0 comments on commit 472e56a

Please sign in to comment.