Monday, April 20, 2020

Could not find acceptable representation .COM PathVariable Spring boot 2

Solution next error.

In your method RESTful web service add.


@GetMapping("/public/file/{url_filename:.*}")

And create next class.

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false).favorParameter(true);
}

}



Caused by: org.hibernate.AnnotationException: No identifier specified for entity

Solution next Error:

you need to add primary key in your table database and  add id(@Id) annotation attribute on your class in java.

Thursday, April 16, 2020

Can't serve static html with Spring Boot 2

Solution next error.

Add next class:

package your_package;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class StaticResourceConfiguration implements WebMvcConfigurer {

 private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
  "classpath:/META-INF/resources/",
  "classpath:/resources/",
  "classpath:/static/",
  "classpath:/public/"
 };

 @Override
 public void addResourceHandlers(ResourceHandlerRegistry registry) {
  registry.addResourceHandler("/**")
   .addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
 }

}


and try again access, for example:

http:localhost:8080/your_html.html

or

http:localhost:8080/your_context/your_html.html













References:
https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot







TypeError: Cannot read property 'kind' of undefined - Angular 8

Solution next error Angular 8:

ERROR in ./node_modules/ng-multiselect-dropdown/fesm5/ng-multiselect-dropdown.js
Module build failed (from ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js):     
TypeError: Cannot read property 'kind' of undefined


Change the version angular-devkit with next command:

npm install @angular-devkit/build-angular@0.803.20


check your package.json




And try again.

ng build --prod /











References:
https://github.com/ckeditor/ckeditor4-angular/issues/78






Virtual Threads in Java 21: Simplified Concurrency for Modern Applications

  With Java 21, Virtual Threads have redefined how we approach concurrency, offering a lightweight and efficient way to handle parallel and ...