diff --git a/README.md b/README.md index 14b734f..a792708 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # spring-react-typescript-boilerplate A boilerplate for spring boot web application with a frontend developed in react & typescript + +Combining [kantega's approach](https://github.com/kantega/react-and-spring) with this [react-typescript0-starter](https://github.com/deepwaterL/react-typescript-boilerplate). \ No newline at end of file diff --git a/frontend/src/components/App.tsx b/frontend/src/components/App.tsx index 3b7498b..98a8ac9 100644 --- a/frontend/src/components/App.tsx +++ b/frontend/src/components/App.tsx @@ -4,13 +4,30 @@ import '../styles/index.css'; export interface IAppProps {} -export interface IAppState {} +export interface IAppState { + response: string +} class App extends React.PureComponent { + + constructor(props: IAppProps) { + super(props); + this.state = {response: 'Loading'}; + } + + componentDidMount(): void { + fetch('api/hello') + .then(response => response.text()) + .then(text => { + this.setState({response: text}); + }); + } + render() { return (

Hello World!

+

{this.state.response}

); } diff --git a/pom.xml b/pom.xml index 0a9757b..a403c7b 100644 --- a/pom.xml +++ b/pom.xml @@ -43,6 +43,65 @@ org.springframework.boot spring-boot-maven-plugin + + + com.github.eirslett + frontend-maven-plugin + 1.6 + + frontend + target + + + + install node and npm + + install-node-and-npm + + + v12.3.1 + 6.14.2 + + + + npm install + + npm + + + install + + + + npm run build + + npm + + + run build + + + + + + + maven-antrun-plugin + + + generate-resources + + + + + + + + + run + + + +