小编use*_*291的帖子

从 Java Web 应用程序发送推送通知

我有一个 Java Web 应用程序,需要向用户发送手动和自动通知。此通知应发送到用户的浏览器以及移动设备(iOS 和 Android)。我发现如果移动设备上没有运行本机应用程序,则无法直接向移动设备发送通知。所以我唯一的选择似乎是网络推送通知。我浏览了几篇文章,发现它很混乱。我不知道从哪里开始。

  1. 我可以直接从 Java 代码发送通知吗?还是我必须使用 FCM(Firebse)?如果是这样,我可以直接从 Java 代码调用 FCM,例如使用 Apache http 客户端库调用它吗?
  2. FCM、客户端的浏览器和我的应用程序如何连接?
  3. 我还发现服务工作者应该在后台运行以接收通知。如何将其与 Java 代码集成?

java push-notification firebase service-worker firebase-cloud-messaging

5
推荐指数
2
解决办法
8429
查看次数

模板引用变量给出 _r0 不是函数错误

我有一个搜索字段,当按下回车键时会触发搜索方法。

 <mat-form-field class="search-field">
    <mat-label>Search</mat-label>
    <input type="text" (keyup.enter)="search($event)"  matInput #search>
    <mat-icon matSuffix>search</mat-icon>
  </mat-form-field>
Run Code Online (Sandbox Code Playgroud)

当我按下搜索按钮时出现以下错误

ERROR TypeError: _r0 is not a function
    at UploadPhotoComponent_Template_input_keyup_enter_4_listener (upload-photo.component.html:4)
    at executeListenerWithErrorHandling (core.js:14296)
    at wrapListenerIn_markDirtyAndPreventDefault (core.js:14331)
    at platform-browser.js:582
    at platform-browser.js:1278
    at ZoneDelegate.invoke (zone-evergreen.js:364)
    at Object.onInvoke (core.js:27149)
    at ZoneDelegate.invoke (zone-evergreen.js:363)
    at Zone.runGuarded (zone-evergreen.js:133)
    at NgZone.runGuarded (core.js:27060)
Run Code Online (Sandbox Code Playgroud)

但是,当我将模板引用变量从 #search 更改为 #searchFiled 时,它工作正常

  <mat-form-field class="search-field">
    <mat-label>Search</mat-label>
    <input type="text" (keyup.enter)="search($event)"  matInput #searchFiled>
    <mat-icon matSuffix>search</mat-icon>
  </mat-form-field>
Run Code Online (Sandbox Code Playgroud)

这是什么原因呢?

angular

5
推荐指数
1
解决办法
2189
查看次数

在docker compose中将文件夹名称添加到容器名称前面的目的是什么

我的 docker compose 文件位于 /documents 文件夹中,当我使用 docker-compose up 时,它将文件夹名称附加到服务名称(myappv1)。

documents_myappv1_1
Run Code Online (Sandbox Code Playgroud)

这样做的目的是什么?为什么不能只是myappv1_1

docker docker-compose

4
推荐指数
1
解决办法
7326
查看次数

Files.readAllBytes() 读取文件后是否关闭输入流?

这个java方法在读取文件后是否关闭输入流?

Files.readAllBytes(Paths.get("文件"))

java file-io inputstream

3
推荐指数
1
解决办法
4145
查看次数

Spring Security在登录后总是返回403 accessDeniedPage

我是Spring的新手,我一直在尝试使用spring security实现一个简单的登录页面.但它总是在提供登录凭据后访问Denied url.在我提供正确的用户名和密码后,loadUserByUsername()方法始终返回用户.但我不知道如何找到返回用户对象后发生的事情.

用户只有一个角色.该方法返回具有SUPER_USER角色的用户.

这是我的spring安全配置类

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationTrustResolver;
import org.springframework.security.authentication.AuthenticationTrustResolverImpl;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@Configuration
@EnableWebSecurity
@ComponentScan(basePackageClasses = AppConfig.class)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    UserDetailsService userDetailsService;

    @Autowired
    public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {

        System.out.println("Inside configureGlobalSecurity method");

        auth.userDetailsService(userDetailsService);
        auth.authenticationProvider(authenticationProvider());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        System.out.println("Inside configure method");
        http.authorizeRequests().antMatchers("/", "/list")
                .access("hasRole('SUPER_USER') or hasRole('NORMAL_USER') or hasRole('CUSTOMER')")
                .and().formLogin().loginPage("/login") …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-security

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