日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

jhipster 配置 mysql_java – 将jhipster后端和前端分成两个项目?

發布時間:2024/7/19 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 jhipster 配置 mysql_java – 将jhipster后端和前端分成两个项目? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我正在嘗試jhipster基于令牌的身份驗證.它完美地運作.

現在,我想在不同的域上運行后端和前端代碼.我怎樣才能做到這一點?

這是我試過的:

>運行yo jhipster并選擇基于令牌的身份驗證選項:

Welcome to the JHipster Generator

? (1/13) What is the base name of your application? jhipster

? (2/13) What is your default Java package name? com.mycompany.myapp

? (3/13) Do you want to use Java 8? Yes (use Java 8)

? (4/13) Which *type* of authentication would you like to use? Token-based authentication (stateless, with a token)

? (5/13) Which *type* of database would you like to use? SQL (H2, MySQL, PostgreSQL)

? (6/13) Which *production* database would you like to use? MySQL

? (7/13) Which *development* database would you like to use? H2 in-memory with Web console

? (8/13) Do you want to use Hibernate 2nd level cache? Yes, with ehcache (local cache, for a single node)

? (9/13) Do you want to use clustered HTTP sessions? No

? (10/13) Do you want to use WebSockets? No

? (11/13) Would you like to use Maven or Gradle for building the backend? Maven (recommended)

? (12/13) Would you like to use Grunt or Gulp.js for building the frontend? Grunt (recommended)

? (13/13) Would you like to use the Compass CSS Authoring Framework? No

...

I'm all done. Running bower install & npm install for you

^C

>將項目的兩個副本設為jhipster / backend和jhipster / frontend

>從后端和前端刪除不需要的文件

rm -rf backend/.bowerrc

rm -rf backend/.jshintrc

rm -rf backend/bower.json

rm -rf backend/Gruntfile.js

rm -rf backend/package.json

rm -rf backend/src/main/webapp

rm -rf backend/src/test/javascript

rm -rf frontend/pom.xml

rm -rf frontend/src/main/java

rm -rf frontend/src/main/resources

rm -rf frontend/src/test/gatling

rm -rf frontend/src/test/java

rm -rf frontend/src/test/resources

>在代碼中進行更改以完全刪除后端/前端依賴項

> frontend / Gruntfile.js

...

var parseVersionFromPomXml = function() {

return '1.2.2.RELEASE';

};

...

browserSync: { ..., proxy: "localhost:8081" }

> frontend / src / main / webapp / scripts / app / app.js

angular.module('jhipsterApp', [...])

.constant('API_URL', 'http://localhost:8080/')

.run( ... )

> frontend / src / main / webapp / scripts / ** / * .service.js

angular.module('jhipsterApp').factory(..., API_URL) {

return $http.post(API_URL + 'api/authenticate', ...);

}

angular.module('jhipsterApp').factory('Account', function Account($resource, API_URL) {

return $resource(API_URL + 'api/account', {}, {...});

}

// Make similar changes in all service files.

> backend / pom.xml

刪除yeoman-maven-plugin

> backend / src / main / java / com / mycompany / myapp / SimpleCORSFilter.java

// Copied from here: https://spring.io/guides/gs/rest-service-cors/

@Component

public class SimpleCORSFilter implements Filter {

public void doFilter(...) {

...

response.setHeader("Access-Control-Allow-Origin", "*");

...

}

}

>跑

>終端標簽#1:BACKEND

cd backend

mvn spring-boot:run

...

[INFO] com.mycompany.myapp.Application - Started Application in 11.529 seconds (JVM running for 12.079)

[INFO] com.mycompany.myapp.Application - Access URLs:

----------------------------------------------------------

Local: http://127.0.0.1:8080

External: http://192.168.56.1:8080

----------------------------------------------------------

>終端標簽#2:FRONTEND

cd frontend/src/main/webapp

npm install -g http-server

http-server

Starting up http-server, serving ./ on: http://0.0.0.0:8081

Hit CTRL-C to stop the server

>終端選項卡#3:GRUNT

cd frontend

bower install

npm install

grunt serve

...

[BS] Proxying: http://localhost:8081

[BS] Access URLs:

-------------------------------------

Local: http://localhost:3000

External: http://10.34.16.128:3000

-------------------------------------

UI: http://localhost:3001

UI External: http://10.34.16.128:3001

-------------------------------------

輸入用戶名:密碼為admin:admin

我們的BACKEND標簽顯示:

[DEBUG] com.mycompany.myapp.security.Http401UnauthorizedEntryPoint - Pre-authenticated entry point called. Rejecting access

顯然,我做錯了什么.它是什么?

總結

以上是生活随笔為你收集整理的jhipster 配置 mysql_java – 将jhipster后端和前端分成两个项目?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。