小编Ayu*_*yub的帖子

如何在IntelliJ中设置spring active profile环境变量

我在eclipse中使用spring boot应用程序(maven项目).当我运行maven项目的测试清理目标时,我想加载活动的配置文件

我在application.properties和application-test.properties中添加了属性spring.profiles.active = test,aop,这没有任何影响.

或者在IntelliJ IDE的命令行选项中将此属性设置为-Dspring.profiles.active = test,当命令为test clean时,aop没有效果.我也尝试在智能中设置Runner的JVM参数

但是当从IntelliJ IDE执行测试用例类时,@ ActiveProfiles("test")有效(右键单击 - >运行TestCaseClass).

有线索吗?

intellij-idea maven spring-boot

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

弹簧启动应用程序显示???字符而不是 unicode

从数据库读取时,我的 dao 类中的日志显示垃圾字符而不是 unicode 字符。Sql developer 显示来自 oracle 数据库的正确值,并且在数据库上设置了正确的 NLS 语言编码。

以下代码适用于标准 jdbc:

connection = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe", "adminuser", "oracle");
Statement st=connection.createStatement();
ResultSet res=st.executeQuery("SELECT menu_item_name from pending_menu_item 
where menu_item_id=6062");

    while(res.next()){
        System.out.println("itemName: "+res.getString(1));
    }
Run Code Online (Sandbox Code Playgroud)

下面是显示垃圾字符的 springboot 项目的 url,我上传到 git hub。https://github.com/AyubOpen/spring-boot-jdbc/

package com.mkyong;

import com.mkyong.dao.CustomerRepository;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
import java.util.List;
import static java.lang.System.exit;

@SpringBootApplication
public class SpringBootConsoleApplication implements CommandLineRunner {

@Autowired
DataSource dataSource;

@Autowired
private CustomerRepository customerRepository;

@Autowired
private JdbcTemplate jdbcTemplate; …
Run Code Online (Sandbox Code Playgroud)

unicode jdbctemplate spring-boot hikaricp

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