I created a spring-boot application using a tutorial and it was built successfully using 'mvn clean install' command. After that I execute the 'mvn spring-boot:run' command to run the application and it also successfully deployed. However, when I was loading the page on the browser by hitting http://localhost:8080/api, it always redirects to http://localhost:8080/login which I had deployed a few months ago. How should I delete deployment related to http://localhost:8080/login?
my controller class is as follows,
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import mat.pathini.model.Customer;
import mat.pathini.repo.CustomerRepository;
#CrossOrigin(origins = "http://localhost:4200")
#RestController
#RequestMapping("/api")
public class CustomerController {
#Autowired
CustomerRepository repository;
#GetMapping("/customers")
public List<Customer> getAllCustomers() {
System.out.println("Get all Customers...");
List<Customer> customers = new ArrayList<>();
repository.findAll().forEach(customers::add);
return customers;
}
#PostMapping("/customer")
public Customer postCustomer(#RequestBody Customer customer) {
Customer _customer = repository.save(new Customer(customer.getName(), customer.getAge()));
return _customer;
}
#DeleteMapping("/customer/{id}")
public ResponseEntity<String> deleteCustomer(#PathVariable("id") long id) {
System.out.println("Delete Customer with ID = " + id + "...");
repository.deleteById(id);
return new ResponseEntity<>("Customer has been deleted!", HttpStatus.OK);
}
#GetMapping("customers/age/{age}")
public List<Customer> findByAge(#PathVariable int age) {
List<Customer> customers = repository.findByAge(age);
return customers;
}
#PutMapping("/customer/{id}")
public ResponseEntity<Customer> updateCustomer(#PathVariable("id") long id, #RequestBody Customer customer) {
System.out.println("Update Customer with ID = " + id + "...");
Optional<Customer> customerData = repository.findById(id);
if (customerData.isPresent()) {
Customer _customer = customerData.get();
_customer.setName(customer.getName());
_customer.setAge(customer.getAge());
_customer.setActive(customer.isActive());
return new ResponseEntity<>(repository.save(_customer), HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
}
The tutorial that I followed is,
https://grokonez.com/frontend/vue-js/spring-boot-vue-js-example-spring-data-jpa-rest-mysql-crud
Logs as follows
> Downloading from central: https://repo.maven.apache.org/maven2/commons-logging/commons-logging-api/1
> .1/commons-logging-api-1.1.jar Downloaded from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-registry
> /2.0.8/maven-plugin-registry-2.0.8.jar (29 kB at 7.8 kB/s) Downloading
> from central:
> https://repo.maven.apache.org/maven2/com/google/collections/google-collect
> ions/1.0/google-collections-1.0.jar Downloaded from central:
> https://repo.maven.apache.org/maven2/commons-logging/commons-logging-api/1.
> 1/commons-logging-api-1.1.jar (45 kB at 10 kB/s) Downloading from
> central:
> https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2
> .8.1/plexus-archiver-2.8.1.jar Downloaded from central:
> https://repo.maven.apache.org/maven2/org/apache/xbean/xbean-reflect/3.4/xbe
> an-reflect-3.4.jar (134 kB at 29 kB/s) Downloading from central:
> https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-io/2.3.2/p
> lexus-io-2.3.2.jar Downloaded from central:
> https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-container-d
> efault/1.5.5/plexus-container-default-1.5.5.jar (217 kB at 47 kB/s)
> Downloading from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-shade-
> plugin/2.2/maven-shade-plugin-2.2.jar Downloaded from central:
> https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.jar
> (3 58 kB at 76 kB/s) Downloading from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/maven-compat/3.0/mav
> en-compat-3.0.jar Downloaded from central:
> https://repo.maven.apache.org/maven2/com/google/collections/google-collecti
> ons/1.0/google-collections-1.0.jar (640 kB at 130 kB/s) Downloading
> from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-provider
> -api/1.0-beta-6/wagon-provider-api-1.0-beta-6.jar Downloaded from central:
> https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/2.
> 8.1/plexus-archiver-2.8.1.jar (143 kB at 29 kB/s) Downloading from central:
> https://repo.maven.apache.org/maven2/asm/asm/3.3.1/asm-3.3.1.jar
> Downloaded from central:
> https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-io/2.3.2/pl
> exus-io-2.3.2.jar (74 kB at 15 kB/s) Downloading from central:
> https://repo.maven.apache.org/maven2/asm/asm-commons/3.3.1/asm-commons-3.3
> .1.jar Downloaded from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-shade-p
> lugin/2.2/maven-shade-plugin-2.2.jar (100 kB at 20 kB/s) Downloading
> from central:
> https://repo.maven.apache.org/maven2/asm/asm-tree/3.3.1/asm-tree-3.3.1.jar
>
> Downloaded from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/maven-compat/3.0/mave
> n-compat-3.0.jar (285 kB at 54 kB/s) Downloading from central:
> https://repo.maven.apache.org/maven2/org/jdom/jdom/1.1/jdom-1.1.jar
> Downloaded from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-provider-
> api/1.0-beta-6/wagon-provider-api-1.0-beta-6.jar (53 kB at 9.9 kB/s)
> Downloading from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-depende
> ncy-tree/2.1/maven-dependency-tree-2.1.jar Downloaded from central:
> https://repo.maven.apache.org/maven2/asm/asm/3.3.1/asm-3.3.1.jar (44
> kB at
> 8.1 kB/s) Downloading from central: https://repo.maven.apache.org/maven2/org/vafer/jdependency/0.7/jdependency
> -0.7.jar Downloaded from central: https://repo.maven.apache.org/maven2/asm/asm-commons/3.3.1/asm-commons-3.3.
> 1.jar (38 kB at 7.0 kB/s) Downloaded from central: https://repo.maven.apache.org/maven2/asm/asm-tree/3.3.1/asm-tree-3.3.1.jar
> (22 kB at 3.9 kB/s) Downloading from central:
> https://repo.maven.apache.org/maven2/commons-io/commons-io/1.3.2/commons-i
> o-1.3.2.jar Downloading from central:
> https://repo.maven.apache.org/maven2/asm/asm-analysis/3.2/asm-analysis-3.2
> .jar Downloaded from central:
> https://repo.maven.apache.org/maven2/org/vafer/jdependency/0.7/jdependency-
> 0.7.jar (12 kB at 2.0 kB/s) Downloading from central: https://repo.maven.apache.org/maven2/asm/asm-util/3.2/asm-util-3.2.jar
> Downloaded from central:
> https://repo.maven.apache.org/maven2/org/jdom/jdom/1.1/jdom-1.1.jar
> (153 kB at 26 kB/s) Downloading from central:
> https://repo.maven.apache.org/maven2/com/google/guava/guava/11.0.2/guava-1
> 1.0.2.jar Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-dependen
> cy-tree/2.1/maven-dependency-tree-2.1.jar (60 kB at 10 kB/s)
> Downloaded from central:
> https://repo.maven.apache.org/maven2/asm/asm-analysis/3.2/asm-analysis-3.2.
> jar (18 kB at 3.0 kB/s) Downloaded from central:
> https://repo.maven.apache.org/maven2/commons-io/commons-io/1.3.2/commons-io
> -1.3.2.jar (88 kB at 15 kB/s) Downloaded from central: https://repo.maven.apache.org/maven2/asm/asm-util/3.2/asm-util-3.2.jar
> (37 kB at 5.8 kB/s) Downloaded from central:
> https://repo.maven.apache.org/maven2/com/google/guava/guava/11.0.2/guava-11
> .0.2.jar (1.6 MB at 222 kB/s) [INFO] [INFO] ---
> maven-install-plugin:2.5.2:install (default-install) #
> spring-boot-restapi-mysql --- Downloading from central:
> https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom
> Downloaded from central:
> https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom
> (998 B at 2.5 kB/s) Downloading from central:
> https://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.6/commo
> ns-codec-1.6.pom Downloaded from central:
> https://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.6/common
> s-codec-1.6.pom (11 kB at 25 kB/s) Downloading from central:
> https://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/22/
> commons-parent-22.pom Downloaded from central:
> https://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/22/c
> ommons-parent-22.pom (42 kB at 97 kB/s) Downloading from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-
> utils/0.4/maven-shared-utils-0.4.pom Downloaded from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-u
> tils/0.4/maven-shared-utils-0.4.pom (4.0 kB at 5.0 kB/s) Downloading
> from central:
> https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar
> Downloading from central:
> https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.
> 15/plexus-utils-3.0.15.jar Downloading from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-
> utils/0.4/maven-shared-utils-0.4.jar Downloading from central:
> https://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.6/commo
> ns-codec-1.6.jar Downloading from central:
> https://repo.maven.apache.org/maven2/classworlds/classworlds/1.1-alpha-2/c
> lassworlds-1.1-alpha-2.jar Downloaded from central:
> https://repo.maven.apache.org/maven2/classworlds/classworlds/1.1-alpha-2/cl
> assworlds-1.1-alpha-2.jar (38 kB at 65 kB/s) Downloaded from central:
> https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar
> (121 kB at 170 kB/s) Downloaded from central:
> https://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.6/common
> s-codec-1.6.jar (233 kB at 271 kB/s) Downloaded from central:
> https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-u
> tils/0.4/maven-shared-utils-0.4.jar (155 kB at 175 kB/s) Downloaded
> from central:
> https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.1
> 5/plexus-utils-3.0.15.jar (239 kB at 253 kB/s) [INFO] Installing
> D:\MyWork\Project\Pathini\matrimonial-api\target\spring-boot-restapi-mysql-0.0.1-S
> NAPSHOT.jar to
> C:\Users\User\.m2\repository\com\grokonez\spring-boot-restapi-mysql\0.0.1-SNAPSHOT\sp
> ring-boot-restapi-mysql-0.0.1-SNAPSHOT.jar [INFO] Installing
> D:\MyWork\Project\Pathini\matrimonial-api\pom.xml to
> C:\Users\User\.m2\repository\
> com\grokonez\spring-boot-restapi-mysql\0.0.1-SNAPSHOT\spring-boot-restapi-mysql-0.0.1-SNAPSHOT.pom
> [INFO]
> ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO]
> ------------------------------------------------------------------------ [INFO] Total time: 03:54 min [INFO] Finished at:
> 2019-09-07T11:45:05+08:00 [INFO]
> ------------------------------------------------------------------------
>
> D:\MyWork\Project\Pathini\matrimonial-api>mvn spring-boot:run [INFO]
> Scanning for projects... [INFO] [INFO] ---------------<
> com.grokonez:spring-boot-restapi-mysql >--------------- [INFO]
> Building SpringBootRestMySQL 0.0.1-SNAPSHOT [INFO]
> --------------------------------[ jar ]--------------------------------- [INFO] [INFO] >>>
> spring-boot-maven-plugin:2.0.5.RELEASE:run (default-cli) >
> test-compile # spring-boot-res tapi-mysql >>> [INFO] [INFO] ---
> maven-resources-plugin:3.0.2:resources (default-resources) #
> spring-boot-restapi-mysql --
> - [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] Copying 0 resource [INFO] [INFO] ---
> maven-compiler-plugin:3.7.0:compile (default-compile) #
> spring-boot-restapi-mysql --- [INFO] Nothing to compile - all classes
> are up to date [INFO] [INFO] ---
> maven-resources-plugin:3.0.2:testResources (default-testResources) #
> spring-boot-restapi- mysql --- [INFO] Using 'UTF-8' encoding to copy
> filtered resources. [INFO] Copying 0 resource [INFO] [INFO] ---
> maven-compiler-plugin:3.7.0:testCompile (default-testCompile) #
> spring-boot-restapi-mysql --- [INFO] Nothing to compile - all classes
> are up to date [INFO] [INFO] <<<
> spring-boot-maven-plugin:2.0.5.RELEASE:run (default-cli) <
> test-compile # spring-boot-res tapi-mysql <<< [INFO] [INFO] [INFO] ---
> spring-boot-maven-plugin:2.0.5.RELEASE:run (default-cli) #
> spring-boot-restapi-mysql ---
>
> . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __
> _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / /
> =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.5.RELEASE)
>
> 2019-09-07 11:55:59.573 INFO 7692 --- [ main]
> SpringBootRestMySqlApplication : Starting
> SpringBootRestMySqlApplication on HP-PC with PID 7692
> (D:\MyWork\Project\Pathini\matrimonia l-api\target\classes started by
> User in D:\MyWork\Project\Pathini\matrimonial-api) 2019-09-07
> 11:55:59.587 INFO 7692 --- [ main]
> SpringBootRestMySqlApplication : No active profile set,
> falling back to default profiles: default 2019-09-07 11:55:59.689
> INFO 7692 --- [ main]
> ConfigServletWebServerApplicationContext : Refreshing
> org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationC
> ontext#7c851b1f: startup date [Sat Sep 07 11:55:59 SGT 2019]; root of
> context hierarchy 2019-09-07 11:56:00.698 WARN 7692 --- [
> main] o.s.b.a.AutoConfigurationPackages :
> #EnableAutoConfiguration was declared on a class in the default
> package. Automatic #Repository and # Entity scanning is not enabled.
> 2019-09-07 11:56:01.254 INFO 7692 --- [ main]
> trationDelegate$BeanPostProcessorChecker : Bean
> 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration'
> of type [o
> rg.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringC
> GLIB$$81417af9] is not eligible for getting processed by all
> BeanPostProcessors (for example: not el igible for auto-proxying)
> 2019-09-07 11:56:02.102 INFO 7692 --- [ main]
> o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with
> port(s): 8080 (http) 2019-09-07 11:56:02.141 INFO 7692 --- [
> main] o.apache.catalina.core.StandardService : Starting service
> [Tomcat] 2019-09-07 11:56:02.141 INFO 7692 --- [ main]
> org.apache.catalina.core.StandardEngine : Starting Servlet Engine:
> Apache Tomcat/8.5.34 2019-09-07 11:56:02.153 INFO 7692 ---
> [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR
> based Apache Tomcat Native library which allows optimal performance in
> production environmen ts was not found on the java.library.path:
> [C:\Program Files\Java\jdk1.8.0_131\bin;C:\Windows\Sun\Ja
> va\bin;C:\Windows\system32;C:\Windows;C:\Program
> Files\Java\jdk1.8.0_131\bin;C:\Program Files\nodejs
> \;D:\MyWork\Project\spring-2.0.4.RELEASE\bin;%PATH%;C:\ProgramData\chocolatey\bin;C:\Program
> Files\A pache\maven\bin;C:\Program Files\Apache\maven\bin;C:\Program
> Files\Git\cmd;C:\Program Files\PuTTY\;C
> :\Users\User\AppData\Roaming\npm;C:\Program Files (x86)\Google\Cloud
> SDK\google-cloud-sdk\bin;D:\MyW
> ork\Project\spring-2.0.4.RELEASE\bin;C:\Program
> Files\Java\jdk1.8.0_131\bin;C:\Program Files\nodejs\
> ;D:\MyWork\Project\spring-2.0.4.RELEASE\bin;C:\Program
> Files\Java\jdk1.8.0_131\bin;C:\Program Files\
> nodejs\;D:\MyWork\Project\spring-2.0.4.RELEASE\bin;C:\Program
> Files\Java\jdk1.8.0_131\bin;C:\Program
> Files\nodejs\;D:\MyWork\Project\spring-2.0.4.RELEASE\bin;C:\Windows\System32;C:\ProgramData\chocola
> tey\bin;C:\Program Files\Apache\maven\bin;C:\Program
> Files\Apache\maven\bin;C:\Program Files\Git\cmd ;C:\Program
> Files\PuTTY\;C:\ProgramData\chocolatey\bin;C:\Program
> Files\Apache\maven\bin;C:\Program Files\Apache\maven\bin;C:\Program
> Files\Git\cmd;C:\Program Files\PuTTY\;C:\ProgramData\chocolatey\bi
> n;C:\Program Files\Apache\maven\bin;C:\Program
> Files\Apache\maven\bin;C:\Program Files\Git\cmd;C:\Pr ogram
> Files\PuTTY\;D:\MyWork\Project\spring-2.0.4.RELEASE\bin;C:\Program
> Files\Java\jdk1.8.0_131\bin ;C:\Program
> Files\nodejs\;D:\MyWork\Project\spring-2.0.4.RELEASE\bin;C:\Program
> Files\Java\jdk1.8.0_
> 131\bin;C:\Program;C:\Users\User\AppData\Local\Programs\Microsoft VS
> Code\bin;.] 2019-09-07 11:56:02.271 INFO 7692 --- [ost-startStop-1]
> o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring
> embedded WebApplicationContext 2019-09-07 11:56:02.272 INFO 7692 ---
> [ost-startStop-1] o.s.web.context.ContextLoader : Root
> WebApplicationContext: initialization completed in 2588 ms 2019-09-07
> 11:56:02.431 INFO 7692 --- [ost-startStop-1]
> o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:
> 'characterEncodingFilter' to: [/*] 2019-09-07 11:56:02.432 INFO 7692
> --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2019-09-07
> 11:56:02.432 INFO 7692 --- [ost-startStop-1]
> o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:
> 'httpPutFormContentFilter' to: [/*] 2019-09-07 11:56:02.432 INFO 7692
> --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2019-09-07
> 11:56:02.433 INFO 7692 --- [ost-startStop-1]
> .s.DelegatingFilterProxyRegistrationBean : Mapping filter:
> 'springSecurityFilterChain' to: [/*] 2019-09-07 11:56:02.434 INFO
> 7692 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean :
> Servlet dispatcherServlet mapped to [/] 2019-09-07 11:56:02.650 INFO
> 7692 --- [ main] com.zaxxer.hikari.HikariDataSource :
> HikariPool-1 - Starting... 2019-09-07 11:56:02.889 INFO 7692 --- [
> main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start
> completed. 2019-09-07 11:56:02.956 INFO 7692 --- [ main]
> j.LocalContainerEntityManagerFactoryBean : Building JPA container
> EntityManagerFactory for persistence unit 'default' 2019-09-07
> 11:56:02.980 INFO 7692 --- [ main]
> o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing
> PersistenceUnitInfo [
> name: default
> ...] 2019-09-07 11:56:03.099 INFO 7692 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core
> {5.2.17.Final} 2019-09-07 11:56:03.101 INFO 7692 --- [
> main] org.hibernate.cfg.Environment : HHH000206:
> hibernate.properties not found 2019-09-07 11:56:03.161 INFO 7692 ---
> [ main] o.hibernate.annotations.common.Version :
> HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 2019-09-07
> 11:56:03.313 INFO 7692 --- [ main]
> org.hibernate.dialect.Dialect : HHH000400: Using dialect:
> org.hibernate.dialect.MySQL5Dialect 2019-09-07 11:56:03.664 INFO 7692
> --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
> 2019-09-07 11:56:03.798 INFO 7692 --- [ main]
> o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path
> [/**/favicon.ico] onto handler of type [class
> org.springframework.web.servlet.resour ce.ResourceHttpRequestHandler]
> 2019-09-07 11:56:04.089 INFO 7692 --- [ main]
> s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for
> #ControllerAdvice:
> org.springframework.boot.web.servlet.context.AnnotationConfigServletW
> ebServerApplicationContext#7c851b1f: startup date [Sat Sep 07 11:55:59
> SGT 2019]; root of context hi erarchy 2019-09-07 11:56:04.155 WARN
> 7692 --- [ main] aWebConfiguration$JpaWebMvcConfiguration :
> spring.jpa.open-in-view is enabled by default. Therefore, database
> queries may be performed during v iew rendering. Explicitly configure
> spring.jpa.open-in-view to disable this warning 2019-09-07
> 11:56:04.219 INFO 7692 --- [ main]
> s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto
> public
> org.springframework.http.ResponseEntity<java.util.Map<java.lang.Stri
> ng, java.lang.Object>>
> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController
> .error(javax.servlet.http.HttpServletRequest) 2019-09-07 11:56:04.221
> INFO 7692 --- [ main]
> s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped
> "{[/error],produces=[text/html]}" onto public
> org.springframework.web.servlet.ModelAndView or
> g.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.
> http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
> 2019-09-07 11:56:04.590 INFO 7692 --- [ main]
> o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path
> [/webjars/**] onto handler of type [class
> org.springframework.web.servlet.resource.R esourceHttpRequestHandler]
> 2019-09-07 11:56:04.591 INFO 7692 --- [ main]
> o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto
> handler of type [class
> org.springframework.web.servlet.resource.ResourceH ttpRequestHandler]
> 2019-09-07 11:56:05.063 INFO 7692 --- [ main]
> .s.s.UserDetailsServiceAutoConfiguration :
>
>
> Using generated security password:
> 994acd24-ee2a-4142-9514-90abd9626efc
>
> 2019-09-07 11:56:05.276 INFO 7692 --- [ main]
> o.s.s.web.DefaultSecurityFilterChain : Creating filter chain:
> org.springframework.security.web.util.matcher.AnyRequestMatcher#1,
> [org.sprin
> gframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#6cae2294,
> org.springf
> ramework.security.web.context.SecurityContextPersistenceFilter#590e1be3,
> org.springframework.securit y.web.header.HeaderWriterFilter#63e37b1a,
> org.springframework.security.web.csrf.CsrfFilter#7b9b58ea,
> org.springframework.security.web.authentication.logout.LogoutFilter#901cc19,
> org.springframework.se
> curity.web.authentication.UsernamePasswordAuthenticationFilter#5bb94950,
> org.springframework.securit
> y.web.authentication.ui.DefaultLoginPageGeneratingFilter#37b2a2c6,
> org.springframework.security.web.
> authentication.www.BasicAuthenticationFilter#12bbd6aa,
> org.springframework.security.web.savedrequest
> .RequestCacheAwareFilter#2dc9fd87,
> org.springframework.security.web.servletapi.SecurityContextHolder
> AwareRequestFilter#53ad8be3,
> org.springframework.security.web.authentication.AnonymousAuthentication
> Filter#f357d9f,
> org.springframework.security.web.session.SessionManagementFilter#1440774b,
> org.sprin
> gframework.security.web.access.ExceptionTranslationFilter#1186a99c,
> org.springframework.security.web
> .access.intercept.FilterSecurityInterceptor#625c3443] 2019-09-07
> 11:56:05.405 INFO 7692 --- [ main]
> o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX
> exposure on startup 2019-09-07 11:56:05.408 INFO 7692 --- [
> main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name
> 'dataSource' has been autodetected for JMX exposure 2019-09-07
> 11:56:05.416 INFO 7692 --- [ main]
> o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource':
> registering with JMX server as MBean
> [com.zaxxer.hikari:name=dataSource, type=HikariDataSource] 2019-09-07
> 11:56:05.465 INFO 7692 --- [ main]
> o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s):
> 8080 (http) with context path '' 2019-09-07 11:56:05.471 INFO 7692
> --- [ main] SpringBootRestMySqlApplication : Started SpringBootRestMySqlApplication in 6.497 seconds (JVM running
> for 10.695) 2019-09-07 11:58:53.412 INFO 7692 --- [nio-8080-exec-1]
> o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring
> FrameworkServlet 'dispatcherServlet' 2019-09-07 11:58:53.413 INFO
> 7692 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet :
> FrameworkServlet 'dispatcherServlet': initialization started
> 2019-09-07 11:58:53.454 INFO 7692 --- [nio-8080-exec-1]
> o.s.web.servlet.DispatcherServlet : FrameworkServlet
> 'dispatcherServlet': initialization completed in 40 ms
You have to delete or comment your dependency "Spring Security" in pom.xml. Because it automatically adds to your Application default /login page for authentication(without configurations and users to login(only generated "user" + "password in your console")).
In your project you have added
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
Now, In order to make it work for production you may have to configure it properly but since you are following tutorial, which leaves you with 2 options, i.e.
either remove this dependency or use default password which is being printed on console, every time you run your application.
Default username:
user
Default password:
Using generated security password:
994acd24-ee2a-4142-9514-90abd9626efc
NOTE this password changes every time you re-run your application and always check console logs for new password
Related
Is there a way to suspend java ( springboot ) unit tests execution when running mvn test and resume them later ?
So I have this test class :
#SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
class JavaAppApplicationTests {
#Test
void contextLoads() {}
#Test
#RepeatedTest(10)
public void testApplication() {
JavaAppApplication javaApp = new JavaAppApplication();
String result = javaApp.sanitize();
assertEquals(result, "{\"key1\":\"value1\",\"type\":\"Booking\",\"sid\":\"A435211\",\"region\":\"ASIA\",\"fetchFromFile\":\"false\",\"service\":\"true\",\"isEom\":\"true\"}");
}
}
And when I run mvn test, I see in the console logs the following :
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.6.6)
2022-05-17 11:00:29.481 INFO 58143 --- [ main] c.e.javaapp.JavaAppApplicationTests : Starting JavaAppApplicationTests using Java 17-internal on neo-VirtualBox with PID 58143 (started by neo in /home/neo/Desktop/spring-vulnerable-app)
2022-05-17 11:00:29.483 INFO 58143 --- [ main] c.e.javaapp.JavaAppApplicationTests : No active profile set, falling back to 1 default profile: "default"
2022-05-17 11:00:30.542 INFO 58143 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-05-17 11:00:30.561 INFO 58143 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-05-17 11:00:30.561 INFO 58143 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.60]
2022-05-17 11:00:30.749 INFO 58143 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-05-17 11:00:30.749 INFO 58143 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1230 ms
2022-05-17 11:00:31.497 INFO 58143 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-05-17 11:00:31.507 INFO 58143 --- [ main] c.e.javaapp.JavaAppApplicationTests : Started JavaAppApplicationTests in 2.452 seconds (JVM running for 3.887)
[INFO] Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4 s - in com.elastisys.javaapp.JavaAppApplicationTests
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 12, Failures: 0, Errors: 0, Skipped: 0
The JavaApplicationTests is started with a specific PID and a defined port and then tests are executed.
What I am looking for is a way to start the application and wait for a specific period before executing all the tests ( like it's suspended )
Thanks in advance
I have created a Spring Boot Application with Spring Initializr. I use Spring Data with MySQL JDBC Connection. I created an docker image with gradle bootBuildImage and start this docker image with docker run --rm -p 8080:80 buchschrank:0.0.1-SNAPSHOT. But startup needs about 2-3 seconds instead of milliseconds:
2021-11-09 16:03:32.238 INFO 1 --- [ main] o.s.nativex.NativeListener : This application is bootstrapped with code generated with Spring AOT
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.6)
2021-11-09 16:03:32.277 INFO 1 --- [ main] o.s.boot.SpringApplication : Starting application using Java 11.0.13 on 2b2e5a51334b with PID 1 (started by cnb in /workspace)
2021-11-09 16:03:32.277 INFO 1 --- [ main] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default
2021-11-09 16:03:32.326 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-11-09 16:03:32.329 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 2 ms. Found 1 JPA repository interfaces.
2021-11-09 16:03:32.388 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 80 (http)
2021-11-09 16:03:32.389 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-11-09 16:03:32.389 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.54]
2021-11-09 16:03:32.395 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-11-09 16:03:32.395 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 116 ms
2021-11-09 16:03:32.412 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-11-09 16:03:32.414 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-11-09 16:03:32.415 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-11-09 16:03:32.417 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-11-09 16:03:33.840 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-11-09 16:03:33.842 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2021-11-09 16:03:34.973 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-11-09 16:03:34.974 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-11-09 16:03:35.033 WARN 1 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-11-09 16:03:35.077 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 80 (http) with context path ''
2021-11-09 16:03:35.078 INFO 1 --- [ main] o.s.boot.SpringApplication : Started application in 2.852 seconds (JVM running for 2.854)
The sourcecode of my example application: https://github.com/lesestunden/buchschrank-backend
Any idea what is wrong with my application setup? Thanks a lot!
Reason was slow initial connection to database. With local running mysql database startup is around 200ms.
I am having an issue with my dockerized webapp. Essentially I have a docker-compose yaml file and when the file is ran, everything seems to boot up smoothly. I can see that the container is running using docker ps. I can see that it is listening to the correct ports, however when I try to connect via my browser, it refuses to connect.
My yaml file
version: '3'
services:
product-search-service:
build: ./product-search-app
ports:
- 8000:5000
product-shipping-service:
build: ./product-shipping-app
ports:
- 9000:5000
website-app:
build: ./web-app
ports:
- 127.0.0.1:8080:80
volumes:
- ./web-app/public-html:/usr/local/apache2/htdocs/
I am connecting via the web browser to 127.0.0.1:8080
The console logs
Starting webstore-services_product-shipping-service_1 ... done Recreating webstore-services_website-app_1 ... done Starting webstore-services_product-search-service_1 ... done Attaching to webstore-services_product-shipping-service_1, webstore-services_product-search-service_1, webstore-services_website-app_1
website-app_1 | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.18.0.4. Set the 'ServerName' directive globally to suppress this message
website-app_1 | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.18.0.4. Set the 'ServerName' directive globally to suppress this message
website-app_1 | [Fri Mar 13 11:09:16.255235 2020] [mpm_event:notice] [pid 1:tid 140304540900680] AH00489: Apache/2.4.41 (Unix) configured -- resuming normal operations
product-search-service_1 |
product-search-service_1 | . ____ _ __ _ _
product-search-service_1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
product-search-service_1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
product-search-service_1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
product-search-service_1 | ' |____| .__|_| |_|_| |_\__, | / / / /
product-search-service_1 | =========|_|==============|___/=/_/_/_/
product-search-service_1 | :: Spring Boot :: (v2.0.5.RELEASE)
product-shipping-service_1 |
product-shipping-service_1 | . ____ _ __ _ _
product-shipping-service_1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
product-shipping-service_1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
product-shipping-service_1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
product-shipping-service_1 | ' |____| .__|_| |_|_| |_\__, | / / / /
product-shipping-service_1 | =========|_|==============|___/=/_/_/_/
product-shipping-service_1 | :: Spring Boot :: (v2.0.5.RELEASE)
product-search-service_1 |
product-search-service_1 | 2020-03-13 11:09:25.557 INFO 1 --- [ main] product.App : Starting App v0.1.0 on 82a04050f513 with PID 1 (/app/product-search-service-0.1.0.jar started by root in /app)
product-shipping-service_1 |
product-shipping-service_1 | 2020-03-13 11:09:25.743 INFO 1 --- [ main] shipping.App : Starting App v0.1.0 on 21735f5ffb12 with PID 1 (/app/product-shipping-service-0.1.0.jar started by root in /app)
product-search-service_1 | 2020-03-13 11:09:25.607 INFO 1 --- [ main] product.App : No active profile set, falling back to default profiles: default
product-shipping-service_1 | 2020-03-13 11:09:25.800 INFO 1 --- [ main] shipping.App : No active profile set, falling back to default profiles: default
product-search-service_1 | 2020-03-13 11:09:26.461 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#3339ad8e: startup date [Fri Mar 13 11:09:26 GMT 2020]; root of context hierarchy
product-shipping-service_1 | 2020-03-13 11:09:26.606 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#3c679bde: startup date [Fri Mar 13 11:09:26 GMT 2020]; root of context hierarchy
product-search-service_1 | 2020-03-13 11:09:41.208 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 5000 (http)
product-search-service_1 | 2020-03-13 11:09:41.583 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
product-search-service_1 | 2020-03-13 11:09:41.584 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34
product-shipping-service_1 | 2020-03-13 11:09:41.540 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 5000 (http)
product-shipping-service_1 | 2020-03-13 11:09:41.914 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
product-shipping-service_1 | 2020-03-13 11:09:41.923 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34
product-search-service_1 | 2020-03-13 11:09:41.708 INFO 1 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
product-search-service_1 | 2020-03-13 11:09:42.613 INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
product-shipping-service_1 | 2020-03-13 11:09:42.043 INFO 1 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
product-shipping-service_1 | 2020-03-13 11:09:42.873 INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
product-search-service_1 | 2020-03-13 11:09:42.615 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 16228 ms
product-search-service_1 | 2020-03-13 11:09:43.319 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
product-search-service_1 | 2020-03-13 11:09:43.355 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
product-search-service_1 | 2020-03-13 11:09:43.364 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
product-search-service_1 | 2020-03-13 11:09:43.370 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
product-shipping-service_1 | 2020-03-13 11:09:42.874 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 16315 ms
product-shipping-service_1 | 2020-03-13 11:09:43.471 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
product-shipping-service_1 | 2020-03-13 11:09:43.505 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
product-shipping-service_1 | 2020-03-13 11:09:43.508 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
product-shipping-service_1 | 2020-03-13 11:09:43.517 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
product-search-service_1 | 2020-03-13 11:09:43.371 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
product-shipping-service_1 | 2020-03-13 11:09:43.521 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
product-search-service_1 | 2020-03-13 11:09:44.733 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-shipping-service_1 | 2020-03-13 11:09:44.846 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-search-service_1 | 2020-03-13 11:09:46.595 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#3339ad8e: startup date [Fri Mar 13 11:09:26 GMT 2020]; root of context hierarchy
product-shipping-service_1 | 2020-03-13 11:09:46.656 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#3c679bde: startup date [Fri Mar 13 11:09:26 GMT 2020]; root of context hierarchy
product-search-service_1 | 2020-03-13 11:09:47.356 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product]}" onto public product.Product product.ProductController.product(java.lang.String)
product-search-service_1 | 2020-03-13 11:09:47.448 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
product-shipping-service_1 | 2020-03-13 11:09:47.426 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/shipping]}" onto public shipping.Shipping shipping.ShippingController.shipping(long)
product-shipping-service_1 | 2020-03-13 11:09:47.491 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
product-search-service_1 | 2020-03-13 11:09:47.451 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
product-search-service_1 | 2020-03-13 11:09:47.758 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-shipping-service_1 | 2020-03-13 11:09:47.495 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
product-shipping-service_1 | 2020-03-13 11:09:47.773 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-search-service_1 | 2020-03-13 11:09:47.763 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-shipping-service_1 | 2020-03-13 11:09:47.778 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-search-service_1 | 2020-03-13 11:09:49.191 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
product-shipping-service_1 | 2020-03-13 11:09:49.232 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
product-shipping-service_1 | 2020-03-13 11:09:49.633 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 5000 (http) with context path ''
product-search-service_1 | 2020-03-13 11:09:49.612 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 5000 (http) with context path ''
I would also like to note that I have been following this tutorial and I can confirm that all prior steps were completed correctly as I have done this multiple times now
https://cpit490.gitlab.io/labs/lab-8/
Are there any logging features I can enable to get a better look at whats happening when I try to connect to 127.0.0.1 ?
EDIT
Attaching screenshot of the error
EDIT 2
Dockerfile for the web-app
FROM httpd:2-alpine
EXPOSE 80
EXPOSE 443
Edit 3
I am using docker toolbox in case this makes any difference. I don't have win10 pro or enterprise so I had to use toolbox
So I have figured out the issue.
Because I am running Docker Toolbox on Win10 home, my docker is running from VirtualBox which has its own IP address. To connect to my webapp, I need to use VB's IP instead of my local host. Win10 home doesn't have a hypervisor so localhost is essentially locked out from me :(
Credit goes to Docker Toolbox - Localhost not working
It seems that you didn't map correctly container's ports with localhost.
Update your yaml file like below:
version: '3'
services:
product-search-service:
build: ./product-search-app
ports:
- 8000:80
- 8001:443
product-shipping-service:
build: ./product-shipping-app
ports:
- 9000:80
- 9001:443
website-app:
build: ./web-app
ports:
- 8080:80
- 8081:443
volumes:
- ./web-app/public-html:/usr/local/apache2/htdocs/
Now you can browse to
localhost:8080 or localhost:8081
I have created a docker file from maven spring boot application and created a docker image and pushed it to my docker registry.
FROM openjdk:8
ADD target/spring-boot-lazy-init-example-0.0.1-SNAPSHOT.jar spring-boot-lazy-init-example-0.0.1-SNAPSHOT.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "spring-boot-lazy-init-example-0.0.1-SNAPSHOT.jar"]
this is the content what I have written inside docker file and created a docker image. I have changed the tag and pushed it to my docker hub repository which I will use for deployment purpose in Kubernetes cluster but before that I have used this docker image for testing purpose. I have used this docker image to run a container and I have also done the port forwarding as application was running on 8080 port by default.
ubuntu#dockerimage-vm:~/spring-boot-lazy-init-example$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
96963/spring-boot-new v1 1e4a8aab28f8 3 days ago 526MB
96963/docker-spring-boot v1 2f2a3b1c23e8 8 days ago 526MB
docker-spring-boot-new latest 2f2a3b1c23e8 8 days ago 526MB
openjdk 8 f8146facf376 2 weeks ago 488MB
ubuntu#dockerimage-vm:~$ sudo docker run -it 96963/spring-boot-new:v1 -p 8085:8080
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.0.M1)
2020-01-17 11:38:21.417 INFO 1 --- [ main] t.l.SpringBootLazyInitExampleApplication : Starting SpringBootLazyInitExampleApplication v0.0.1-SNAPSHOT on 03ab2d24c370 with PID 1 (/spring-boot-lazy-init-example-0.0.1-SNAPSHOT.jar started by root in /)
2020-01-17 11:38:21.426 INFO 1 --- [ main] t.l.SpringBootLazyInitExampleApplication : No active profile set, falling back to default profiles: default
2020-01-17 11:38:23.355 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2020-01-17 11:38:23.451 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 67ms. Found 0 repository interfaces.
2020-01-17 11:38:24.391 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$cf2fe8c5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-01-17 11:38:25.625 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-01-17 11:38:26.191 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-01-17 11:38:26.192 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16]
2020-01-17 11:38:26.258 INFO 1 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2020-01-17 11:38:26.486 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-01-17 11:38:26.489 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4929 ms
2020-01-17 11:38:27.532 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-01-17 11:38:28.182 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-01-17 11:38:28.398 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2020-01-17 11:38:28.627 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.4.0.Final}
2020-01-17 11:38:28.640 INFO 1 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2020-01-17 11:38:29.171 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-01-17 11:38:29.438 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-01-17 11:38:30.312 INFO 1 --- [ main] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#1b11171f'
2020-01-17 11:38:30.337 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-01-17 11:38:30.339 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-01-17 11:38:30.694 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-01-17 11:38:30.701 INFO 1 --- [ main] t.l.SpringBootLazyInitExampleApplication : Started SpringBootLazyInitExampleApplication in 10.338 seconds (JVM running for 11.976)
2020-01-17 12:08:38.990 WARN 1 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=28m10s615ms885µs724ns)
I have also tried to run the application from local machine and I am able to reach the url
but while I am trying to reach the application which is running inside docker container I am not able to reach. I am accessing that from 192.168.64.3:8085/lazy, (8085 because I have done the port forwarding at that port).
I am trying to get a spring-boot application to run. However with my current settings I keep getting errors.
Java 8
Maven 3.6.1
Environment Variables checked
As of the new version 2.2.1 of spring-boot I keep getting the same error on closing the built-in tomcat.
I have a sample Spring-Boot Application which I can't seem to run properly. Took a clean version from spring initializr.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.547 s
[INFO] Finished at: 2019-11-07T22:28:54+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEASE:run (default-cli) on project java13-app: Application finished with exit code: 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
When I go back to Spring 2.1.10 I get the following output.:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.10.RELEASE)
2019-11-07 22:38:33.194 INFO 2572 --- [ main] test.Application : Starting Application on DP-BTO-Tom with PID 2572 (Y:\tbrx\java-13-spring-boot\target\classes started by Tom in Y:\tbrx\java-13-spring-boot)
2019-11-07 22:38:33.196 INFO 2572 --- [ main] test.Application : No active profile set, falling back to default profiles: default
2019-11-07 22:38:33.966 INFO 2572 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-11-07 22:38:33.986 INFO 2572 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-11-07 22:38:33.986 INFO 2572 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.27]
2019-11-07 22:38:34.053 INFO 2572 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-11-07 22:38:34.054 INFO 2572 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 832 ms
2019-11-07 22:38:34.221 INFO 2572 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-11-07 22:38:34.361 INFO 2572 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-11-07 22:38:34.364 INFO 2572 --- [ main] test.Application : Started Application in 1.542 seconds (JVM running for 4.547)
2019-11-07 22:38:35.652 INFO 2572 --- [ Thread-5] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
[Terminate batch job (Y/N)? y
Instead of a build failure.
Asked, fixed and closed as a bug in Spring Boot - 2.2.1
https://github.com/spring-projects/spring-boot/issues/18936#event-2782909196