JAVA-29231 Move modules inside existing container modules (#15492)
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableMongoRepositories
|
||||
public class SpringJMeterJenkinsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringJMeterJenkinsApplication.class, args);
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.baeldung.configuration;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@Configuration
|
||||
public class WebSecurityConfiguration {
|
||||
|
||||
@Bean
|
||||
public InMemoryUserDetailsManager userDetailsService() {
|
||||
PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
||||
|
||||
Set<UserDetails> users = new HashSet<>();
|
||||
users.add(User.withUsername("admin").password(encoder.encode("admin")).roles("USER", "ADMIN").build());
|
||||
for(int i=1;i<=10;i++){
|
||||
users.add(User.withUsername("user"+i).password(encoder.encode("password")+i).roles("USER").build());
|
||||
}
|
||||
|
||||
return new InMemoryUserDetailsManager(users);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilter(HttpSecurity http) throws Exception {
|
||||
|
||||
http
|
||||
.authorizeRequests()
|
||||
.antMatchers("/secured/**").authenticated()
|
||||
.anyRequest().permitAll()
|
||||
.and()
|
||||
.httpBasic();
|
||||
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.controller;
|
||||
|
||||
import com.baeldung.model.Response;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
@RestController
|
||||
public class RetrieveUuidController {
|
||||
|
||||
@GetMapping("/api/uuid")
|
||||
public Response uuid() {
|
||||
return new Response(format("Test message... %s.", UUID.randomUUID()));
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.baeldung.controller;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.baeldung.model.Response;
|
||||
|
||||
@RestController
|
||||
public class SecuredUuidController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SecuredUuidController.class);
|
||||
|
||||
@GetMapping("/secured/uuid")
|
||||
public Response uuid() {
|
||||
|
||||
LOGGER.info("Returning response");
|
||||
|
||||
return new Response(String.format("Secured test message... %s.", UUID.randomUUID()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.dashboard;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Profile("JMeter-Dashboard")
|
||||
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class, MongoAutoConfiguration.class, MongoRepositoriesAutoConfiguration.class, MongoDataAutoConfiguration.class })
|
||||
public class DashboardApplication {
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(DashboardApplication.class, args);
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.baeldung.dashboard.controllers;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Random;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import com.baeldung.dashboard.models.Quotes;
|
||||
|
||||
@Controller
|
||||
public class Dashboard {
|
||||
|
||||
@GetMapping("/greeting")
|
||||
public String getGreeting(Model model) {
|
||||
model.addAttribute("host", System.getProperty("os.name"));
|
||||
return "greeting";
|
||||
}
|
||||
|
||||
@GetMapping("/quote")
|
||||
public String getQuote(Model model) throws InterruptedException {
|
||||
Random r = new Random();
|
||||
int day = r.nextInt(7);
|
||||
String quote = Quotes.list.get(day);
|
||||
|
||||
int wait = r.nextInt(6);
|
||||
Thread.currentThread().sleep(wait);
|
||||
model.addAttribute("quote", quote);
|
||||
|
||||
return "quote";
|
||||
}
|
||||
|
||||
@GetMapping("/time")
|
||||
public String getTime(Model model) {
|
||||
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("hh:mm:ss a");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
model.addAttribute("time", fmt.format(now));
|
||||
return "time";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.dashboard.models;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Quotes {
|
||||
public static final List<String> list = Arrays.asList("The greatest glory in living lies not in never falling, but in rising every time we fall. -Nelson Mandela\r\n",
|
||||
"The way to get started is to quit talking and begin doing. -Walt Disney\r\n",
|
||||
"Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma – which is living with the results of other people's thinking. -Steve Jobs\r\n",
|
||||
"If life were predictable it would cease to be life, and be without flavor. -Eleanor Roosevelt\r\n",
|
||||
"If you look at what you have in life, you'll always have more. If you look at what you don't have in life, you'll never have enough. -Oprah Winfrey\r\n",
|
||||
"If you set your goals ridiculously high and it's a failure, you will fail above everyone else's success. -James Cameron\r\n", "Life is what happens when you're busy making other plans. -John Lennon");
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.baeldung.domain;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Document(collection = "STUDENT")
|
||||
public class Student implements Serializable {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
@NotNull
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
@NotNull
|
||||
private String phoneNumber;
|
||||
private String email;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Student{" +
|
||||
"firstName='" + firstName + '\'' +
|
||||
", lastName='" + lastName + '\'' +
|
||||
", phoneNumber='" + phoneNumber + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.baeldung.model;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Response {
|
||||
private Instant timestamp;
|
||||
private UUID uuid;
|
||||
private String message;
|
||||
|
||||
public Response(String message) {
|
||||
this.timestamp = Instant.now();
|
||||
this.uuid = UUID.randomUUID();
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Instant getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Instant timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.baeldung.repository;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import com.baeldung.domain.Student;
|
||||
|
||||
public interface StudentRepository extends MongoRepository<Student, String> {
|
||||
}
|
||||
Reference in New Issue
Block a user