小编Fab*_*ner的帖子

如何在Spring Boot中设置默认环境

如何在Spring Boot中设置默认环境?

我投入application.properties:

spring.profiles.include=prod,dev
spring.profiles.active=prod
Run Code Online (Sandbox Code Playgroud)

在用户变量中:

SPRING_PROFILES_ACTIVE = dev
Run Code Online (Sandbox Code Playgroud)

因此,当我开发我的环境时,我的环境是dev,但是当我生成我的.war并在tomcat中部署时,他仍然使用dev环境(我在另一个comp中部署而没有其他conf)

如何设置我的默认环境(如果他在用户变量或命令行中没有找到任何产品)?

environment-variables spring-boot

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

使用Springboot在MongoTemplate中注册CustomConverter

如何在我的mongoTemplate中使用Spring启动注册自定义转换器?我只使用注释,它可能吗?

TKS

spring-data-mongodb spring-boot

8
推荐指数
3
解决办法
6182
查看次数

Springboot的logback配置

我尝试配置我的springboot应用程序一天登录一个文件,所以我配置我的logback.xml就像这样:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>

    <appender name="ROLLIN" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_FILE}</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

            <!-- daily rollover -->
            <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern>

        </rollingPolicy>
    </appender>

    <root level="INFO">
        <appender-ref ref="ROLLIN" />
    </root>

    <logger name="org.springframework.web" level="INFO"/>
</configuration>
Run Code Online (Sandbox Code Playgroud)

因此,当我尝试运行我的应用程序时,我收到此错误:

Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[ROLLIN] - No encoder set for the appender named "ROLLIN".
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:151)
    at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:71)
    at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:49)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:106)
    at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:301)
    at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:253)
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:225)
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:201)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:119)
    at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:65)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) …
Run Code Online (Sandbox Code Playgroud)

logback spring-boot

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

使用Spring Boot记录MongoDB查询

是否可以在Spring Boot应用程序中记录所有MongoDB查询?我试过这个:

logging.level.org.springframework.data.document.mongodb=INFO
log4j.category.org.springframework.data.document.mongodb=INFO
Run Code Online (Sandbox Code Playgroud)

但它没有用.

mongodb spring-boot

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

axios 拦截器中的 Vue-Router

我用 vue-cli 3 创建了一个项目,所以我运行:

>vue create my-app;
>cd my-app
>vue add axios
Run Code Online (Sandbox Code Playgroud)

vue 在 my-app\src\plugins\ 中使用以下代码创建文件 axios.js:

"use strict";

import Vue from 'vue';
import axios from "axios";

// Full config:  https://github.com/axios/axios#request-config
// axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || '';
// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

let config = {
  // baseURL: process.env.baseURL || process.env.apiUrl || ""
  // timeout: 60 * 1000, // Timeout
  // withCredentials: true, // Check cross-site Access-Control
};

const _axios = axios.create(config);

_axios.interceptors.request.use(
  function(config) { …
Run Code Online (Sandbox Code Playgroud)

vue.js vue-router axios vuejs2

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

如何使用freemarker通过springboot发送电子邮件

我如何使用freemarker发送带有spring-boot的电子邮件?我看一下spring-boot示例,但没有找到任何东西

我想用我的模板生成电子邮件正文

TKS

freemarker spring-boot

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

在 Spring Boot 中使用 2 个数据库的 Flyway

我将Spring BootFlyway一起使用,现在我需要将它与 2 个数据库一起使用,今天这是我的属性文件:

flyway.validateOnMigrate=false
flyway.baselineOnMigrate=true
flyway.check-location=false
flyway.locations=classpath:db/migration
flyway.sql-migration-prefix=V
flyway.sql-migration-suffix=.sql
flyway.enabled=true
Run Code Online (Sandbox Code Playgroud)

那么如何配置以使用另一个连接(与我的迁移中的另一个目录)?

java spring flyway spring-boot

5
推荐指数
0
解决办法
2233
查看次数

Springboot HikariCP

我将 springboot 与 HikariCP 一起使用,但过了一段时间我的应用程序崩溃并出现错误:

org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
...

Caused by: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection

....
Caused by: java.sql.SQLTransientConnectionException: HikariPool-6 - Connection is not available, request timed out after 30000ms.
Run Code Online (Sandbox Code Playgroud)

这是我的 aplication.properties

spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:postgresql://localhost:5432/db_dnaso
#spring.datasource.url=jdbc:postgresql://172.16.1.10:5432/db_dnaso
spring.datasource.username=postgres
spring.datasource.password=dna44100
spring.datasource.driver-class-name=org.postgresql.Driver
Run Code Online (Sandbox Code Playgroud)

所以我有很多保存、查找和其他人访问数据库的权限,我如何可视化方法如何阻止我的连接?

tks

postgresql spring-data-jpa spring-boot hikaricp

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

通过在Vue.js的动态组件中指定可能不使用的值,我会失去性能吗?

在我的应用中,我有10个组件,所有这些组件都需要一个名为andamento; 的属性。但只有一个子集需要一个名为的属性custas

如果我在(下)中custas所有组件设置了属性,那么andamentosOrdenado与仅为子集设置属性相比,我是否会失去性能?

这是我的代码:

<v-timeline-item class="mb-3" small v-for="andamento in andamentosOrdenado" :key="andamento.nome">
  <component v-bind:is="andamento.form" :andamento="andamento" :custas="notificacao.custas"></component>
</v-timeline-item>
Run Code Online (Sandbox Code Playgroud)

javascript vue.js

5
推荐指数
0
解决办法
47
查看次数

Springboot Keycloak Admin添加角色或重置密码错误

我尝试使用管理客户端在我的 keycloak 中创建一个新用户

用这个代码:

package br.com.fabioebner.surfpp.api.serivce;

import lombok.extern.slf4j.Slf4j;
import org.keycloak.OAuth2Constants;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
import org.keycloak.admin.client.resource.*;
import org.keycloak.representations.idm.*;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;

import javax.ws.rs.core.Response;
import java.util.*;

@Service
@Slf4j
public class KeycloakService {
    private final RealmResource realm;
    private final Keycloak keycloak;

    public KeycloakService() {
        this.keycloak = Keycloak.getInstance(
                "https://myKey/auth/",
                "master",
                "admin",
                "myPass",
                "admin-cli");
        this.realm = keycloak.realm("myRealm");
    }

    @EventListener(ApplicationReadyEvent.class)
    public void addUser(){
        UsersResource users = realm.users();
        ClientResource api = realm.clients().get("api");
//        RoleResource usuario = api.roles().get("USUARIO");
        UserRepresentation novoUsuario = new UserRepresentation();
        novoUsuario.setUsername("joao"); …
Run Code Online (Sandbox Code Playgroud)

java oauth-2.0 spring-boot spring-security-oauth2 keycloak

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