Giter Site home page Giter Site logo

adora-tech / spboot2ng Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mamunsrdr/spboot2ng

0.0 1.0 0.0 159 KB

A spring boot 2 and angular 6 starter project

Home Page: https://mamunsrdr.github.io/spboot2ng/

JavaScript 13.07% Java 28.31% TypeScript 55.44% HTML 3.19%

spboot2ng's Introduction

Spring boot 2 Ng 6 Build Status

A Spring boot 2 and angular 6 starter project

What's included

  • spring boot 2.0.5
  • angular: 6.1.0

Project structure

Angular app will be placed under src/main/resources/static directory after build

"outputPath": "src/main/resources/static",

//moved environment under app
"replace": "src/app/environments/environment.ts",
"with": "src/app/environments/environment.prod.ts"

Also added template resolver config to resolve index.html view from static folder

@Bean
public ITemplateResolver clientTemplateResolver() {
    SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setPrefix("classpath:/static/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setCacheable(false);
    resolver.setOrder(1);
    return resolver;
}

@Bean
public TemplateEngine appTemplateEngine() {
    ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
    resolver.setSuffix(".html");
    resolver.setCharacterEncoding("UTF-8");
    resolver.setTemplateMode(TemplateMode.HTML);
    TemplateEngine templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(resolver);
    return templateEngine;
}

Gradle plugin and tasks

buildscript {
    // ... other configs ...
    repositories {
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        // ... other classpath dependencies ...
        classpath "com.moowork.gradle:gradle-node-plugin:1.2.0"
    }
}
// apply plugin
apply plugin: "com.moowork.node"
node {
    version = "10.8.0"
    npmVersion = '6.2.0'
    download = true
}

task buildApp(type: NpmTask, dependsOn: 'npmInstall') {
    group = 'build'
    args = ['run', 'build']
}

task buildWatch(type: NpmTask, dependsOn: 'npmInstall') {
    group = 'application'
    args = ['run', 'buildWatch']
}

clean {
    def ft = fileTree('src/main/resources/static')
    ft.visit { FileVisitDetails fvd ->
        delete fvd.file
    }
}

war {
    dependsOn 'buildApp'
}

Sample command

// to build war with angular app
# gradlew bootRun

// run this watcher task
# ./gradlew buildWatch
// or for win
# gradlew buildWatch

// build war file as usual
# gradlew assemble

// normal build
# gradlew build

Personally in IntelliJ idea I like to run debug window and terminal (gradlew buildWatch) side by side like this: Screenshot

spboot2ng's People

Contributors

mamunsrdr avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.