add angular material project as embedded in spring
This commit is contained in:
@@ -39,3 +39,4 @@ out/
|
|||||||
/gradle/wrapper/gradle-wrapper.properties
|
/gradle/wrapper/gradle-wrapper.properties
|
||||||
/.gitattributes
|
/.gitattributes
|
||||||
/gradle/
|
/gradle/
|
||||||
|
/src/main/resources/public/
|
||||||
|
|||||||
@@ -32,6 +32,34 @@ dependencies {
|
|||||||
implementation 'org.postgresql:postgresql:42.6.0'
|
implementation 'org.postgresql:postgresql:42.6.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copyResouces( type:Copy
|
||||||
|
|
||||||
|
//tasks copyResouces( type:Copy){
|
||||||
|
//
|
||||||
|
// def buildDir = "${project.buildDir}"
|
||||||
|
//
|
||||||
|
// from "{$buildDir}/jambotron-ui/dist/jambotron-ui/browser" // Source directory
|
||||||
|
// into "{$buildDir}/build/resources" // Target directory
|
||||||
|
// include '**/*'
|
||||||
|
//}
|
||||||
|
|
||||||
|
apply plugin: 'java'
|
||||||
|
|
||||||
|
tasks.register('copyResources', Copy) {
|
||||||
|
from 'jambotron-ui/dist/jambotron-ui/browser'
|
||||||
|
into 'src/main/resources/public'
|
||||||
|
}
|
||||||
|
processResources.dependsOn(copyResources)
|
||||||
|
compileJava.dependsOn(copyResources)
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
resources {
|
||||||
|
srcDir 'jambotron-ui/dist/jambotron-ui/browser'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tasks.named('test') {
|
tasks.named('test') {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+17
@@ -8,6 +8,7 @@
|
|||||||
"name": "jambotron-ui",
|
"name": "jambotron-ui",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@angular/animations": "^20.0.3",
|
||||||
"@angular/cdk": "^20.0.3",
|
"@angular/cdk": "^20.0.3",
|
||||||
"@angular/common": "^20.0.0",
|
"@angular/common": "^20.0.0",
|
||||||
"@angular/compiler": "^20.0.0",
|
"@angular/compiler": "^20.0.0",
|
||||||
@@ -117,6 +118,22 @@
|
|||||||
"yarn": ">= 1.13.0"
|
"yarn": ">= 1.13.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@angular/animations": {
|
||||||
|
"version": "20.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@angular/animations/-/animations-20.0.3.tgz",
|
||||||
|
"integrity": "sha512-R6yv2RmrH49nW1ybgoOMw5pWzqaRYo8Kn3VtvrUDBty4TXjwc0addaw/t89n0smO3/lmBB4vnlRScePAEQZ/3w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.3.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@angular/common": "20.0.3",
|
||||||
|
"@angular/core": "20.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@angular/build": {
|
"node_modules/@angular/build": {
|
||||||
"version": "20.0.2",
|
"version": "20.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@angular/build/-/build-20.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@angular/build/-/build-20.0.2.tgz",
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@angular/animations": "^20.0.3",
|
||||||
"@angular/cdk": "^20.0.3",
|
"@angular/cdk": "^20.0.3",
|
||||||
"@angular/common": "^20.0.0",
|
"@angular/common": "^20.0.0",
|
||||||
"@angular/compiler": "^20.0.0",
|
"@angular/compiler": "^20.0.0",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { bootstrapApplication } from '@angular/platform-browser';
|
|||||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
import {AppModule} from './app/app.module';
|
import {AppModule} from './app/app.module';
|
||||||
|
//import('@angular/animations/browser')
|
||||||
|
|
||||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.jambotronGroup.jambotron;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
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 MvcConfig implements WebMvcConfigurer {
|
||||||
|
@Value("${spring.resources.static-locations}")
|
||||||
|
String resourceLocations;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
registry.addResourceHandler("/public/**").addResourceLocations(resourceLocations);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.jambotronGroup.jambotron;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.util.ResourceUtils;
|
||||||
|
import org.springframework.util.StreamUtils;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
@ControllerAdvice
|
||||||
|
public class NotFoundHandler {
|
||||||
|
@Value("${spa.default-file}")
|
||||||
|
String defaultFile;
|
||||||
|
|
||||||
|
@ExceptionHandler(NoHandlerFoundException.class)
|
||||||
|
public ResponseEntity<String> renderDefaultPage() {
|
||||||
|
try {
|
||||||
|
File indexFile = ResourceUtils.getFile(defaultFile);
|
||||||
|
FileInputStream inputStream = new FileInputStream(indexFile);
|
||||||
|
String body = StreamUtils.copyToString(inputStream, Charset.defaultCharset());
|
||||||
|
return ResponseEntity.ok().contentType(MediaType.TEXT_HTML).body(body);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There was an error completing the action.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,3 +15,12 @@ app.jwtSecret= ======================spring=back====================
|
|||||||
app.jwtExpirationMs= 30000
|
app.jwtExpirationMs= 30000
|
||||||
app.jwtCookieName=springangularts
|
app.jwtCookieName=springangularts
|
||||||
app.origin=http://localhost:4200
|
app.origin=http://localhost:4200
|
||||||
|
|
||||||
|
spring.mvc.throw-exception-if-no-handler-found=true
|
||||||
|
|
||||||
|
# Disable the default mappings
|
||||||
|
spring.resources.add-mappings=false
|
||||||
|
|
||||||
|
spring.resources.static-locations=classpath:/public
|
||||||
|
spring.resources.cache.period=31557600s # 1 year if you want
|
||||||
|
spa.default-file=classpath:/public/browser/index.html
|
||||||
|
|||||||
Reference in New Issue
Block a user