小编Fra*_*nky的帖子

Angular 9 Universal ReferenceError:窗口未定义

我正在尝试使用一些第三方库在 angular 9 项目上设置 SSR,但没有成功。

下面的错误

ReferenceError: window is not defined
at ./node_modules/intl-tel-input/build/js/intlTelInput.js (main.js:295050:32)
at Object../node_modules/intl-tel-input/build/js/intlTelInput.js (main.js:295052:3)
at __webpack_require__ (main.js:20:30)
at Object../node_modules/intl-tel-input/index.js (main.js:296381:18)
at __webpack_require__ (main.js:20:30)
at Module../node_modules/intl-tel-input-ng/__ivy_ngcc__/fesm2015/intl-tel-input-ng.js (main.js:294832:72)
at __webpack_require__ (main.js:20:30)
    at Object.. main.js:463107:29)
    at __webpack_require__ (main.js:20:30)
    at Object.. main.js:462977:33)
A server error has occurred.
node exited with 1 code.
connect ECONNREFUSED 127.0.0.1:50362
Run Code Online (Sandbox Code Playgroud)

我无权访问服务器端的 window 对象,这是正常的,所以为了避免这个错误,我正在检查平台并在需要 intl-tel-input lib 的组件中使用条件逻辑......但没有成功。

如何在 SSR 时修复窗口、导航器、文档错误?

在 package.json 文件下面

    {
  "name": "dz",
  "version": "0.0.0",
  "scripts": {

    "compile:server_bak": "webpack --mode production --config webpack.server.config.js --progress …
Run Code Online (Sandbox Code Playgroud)

node.js server-side-rendering angular

8
推荐指数
1
解决办法
3164
查看次数

ng-build上的端口和代理配置

我有一个前端在int.myapp.com上运行,它是在int.backend.myapp.com上的后端.我以为我可以像这样使用proxy.config.json进行代理:

 "/api": {
    "target": "https://int.backend.myapp.com",
    "secure": true,
    "changeOrigin": true
  }
Run Code Online (Sandbox Code Playgroud)

在我的package.json文件中

"start": "ng serve --proxy-config proxy.conf.json"
Run Code Online (Sandbox Code Playgroud)

一切都适用于我的开发环境.

但是当我为生产而建立:

ng buil --prod
Run Code Online (Sandbox Code Playgroud)

并部署在firebase上

firebase deploy
Run Code Online (Sandbox Code Playgroud)

Web应用程序无法与API通信

我该怎么做才能解决它?

firebase firebase-hosting angular-cli angular

7
推荐指数
2
解决办法
3889
查看次数

javax.persistence.PersistenceException:无效的persistence.xml

我正在使用eclipse中的Servlet,JPA,EJB和JBoss进行项目.正如您在我的主题标题中看到的,我的persistence.xml文件有错误,但我不知道哪个:

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="TrainingAppEJB-PU">
        <provider>org.hibernate.ejb.HibernatePersistence</provider> 
        <jta-data-source>java:jboss/datasources/MysqlDS</jta-data-source>
        <class>fr.entity.Client</class>
        <class>fr.entity.Course</class>
        <class>fr.entity.CourseSession</class>
        <class>fr.entity.Location</class>

        <properties>
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/gestion_formation"/>
            <property name="hibernate.default_schema" value="gestion_formation"/>
            <property name="hibernate.connection.username" value="root"/>
            <property name="hibernate.connection.password" value="********"/>
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="show_sql" value="true"/>
        </properties>
    </persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)

但是当我尝试运行我的servlet时,我遇到了这个错误:

  16:59:44,498 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/TrainingAppWeb].[Home]] (http--127.0.0.1-8080-2) "Servlet.service()" pour la servlet Home a généré une exception: javax.ejb.EJBException: javax.persistence.PersistenceException: Invalid persistence.xml.
Error parsing XML (line-1 : column -1): cvc-elt.1: Cannot find the declaration of element 'persistence'.

    at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:206)
    at …
Run Code Online (Sandbox Code Playgroud)

hibernate servlets jpa ejb-3.1 jboss7.x

2
推荐指数
1
解决办法
1万
查看次数