这个问题的答案已经很少了。但它们都不适合我。
我一生都无法弄清楚为什么会出现错误。
以下是我尝试过的方法:
每当我尝试在 Maven 构建期间或在 Tomcat 上部署时运行测试时,都会出现以下错误
这是配置。
package com.fordit.project.config;
@Configuration
@EnableMongoRepositories(basePackages = "com.company.project")
@ComponentScan(basePackages = "com.company.project")
public class ProjectConfiguration {
@Value("${project.db.driver_class}")
private String driverClassname;
@Value("${project.db.connection_string}")
private String connectionString;
@Bean
public DataSource dataSource() throws PropertyVetoException {
Properties mysqlProperties = new Properties();
mysqlProperties.setProperty("characterEncoding", "UTF-8");
mysqlProperties.setProperty("useUnicode", "true");
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setProperties(mysqlProperties);
cpds.setDriverClass(driverClassname);
cpds.setJdbcUrl(connectionString);
cpds.setAcquireIncrement(2);
return cpds;
}
@Bean
public static PropertyPlaceholderConfigurer getPropertyPlaceholderConfigurer() throws IOException {
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
ResourceLoader resourceLoader …
Run Code Online (Sandbox Code Playgroud)