我的控制器
@RestController
public class CheckUserDataRestController {
private final UserSearchService userSearchService;
@Autowired
public CheckUserDataRestController(final UserSearchService userSearchService) {
this.userSearchService = userSearchService;
}
...
}
Run Code Online (Sandbox Code Playgroud)
初始化 bean 服务
@Service("userSearchService")
public class UserSearchServiceImpl implements UserSearchService {
private final UserRepository userRepository;
private final AuthorizationService authorizationService;
@Autowired
public UserSearchServiceImpl(
@NotNull final UserRepository userRepository,
@NotNull final AuthorizationService authorizationService
) {
this.userRepository = userRepository;
this.authorizationService = authorizationService;
}
...
}
Run Code Online (Sandbox Code Playgroud)
初始化另一个服务 bean
@Service("authorizationService")
public class AuthorizationServiceImpl implements AuthorizationService {
private final UserSearchService userSearchService;
@Autowired
public AuthorizationServiceImpl(final UserSearchService userSearchService) …Run Code Online (Sandbox Code Playgroud) I create an application in Spring Boot 2.0.0. I use HikariCP by default. The application.yml file for the PostgreSQL database looked like this
spring:
datasource:
driver-class-name: org.postgresql.Driver
jdbcUrl: jdbc:postgresql:database
username: root
password: root
type: com.zaxxer.hikari.HikariDataSource
# Hikari
poolName: SpringBootHikariCP
maximumPoolSize: 5
minimumIdle: 3
maxLifetime: 2000000
connectionTimeout: 30000
idleTimeout: 30000
pool-prepared-statements: true
max-open-prepared-statements: 250
connection-test-query: SELECT 1
eclipse-link:
database-platform: org.eclipse.persistence.platform.database.PostgreSQLPlatform
generate-dll: true
show-sql: true
weaving: static
Run Code Online (Sandbox Code Playgroud)
The PostgreSQL application works without a problem. After I tried to change the database …
我有build.gradle该项目的主文件
buildscript {
repositories {
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${spring_boot_version}")
}
}
def javaProjects = subprojects.findAll {
it.name in ["common", "core", "web", "app"]
}
allprojects {
apply plugin: 'idea'
apply plugin: 'eclipse'
repositories {
jcenter()
}
}
idea {
project {
jdkName = "1.8"
languageLevel = "1.8"
vcs = "Git"
}
}
configure(javaProjects) {
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'findbugs'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
...
}
}
Run Code Online (Sandbox Code Playgroud)
和模块的build.gradle文件app …
我在对象中有一个变量:
private final Map<Long, ? extends MovieInfoDTO> bElementsToAdd = new HashMap<>();
Run Code Online (Sandbox Code Playgroud)
使用Builder模式中的方法我想完成这个地图。
public Builder withElementsToAdd(@Nullable final Map<Long, ? extends MovieInfoDTO> elementsToAdd) {
this.bElementsToAdd.clear();
if(elementsToAdd != null) {
this.bElementsToAdd.putAll(elementsToAdd);
}
return this;
}
Run Code Online (Sandbox Code Playgroud)
但是,我收到一个错误。
putAll
(java.util.Map<? extends java.lang.Long,? extends capture<? extends com.jonki.popcorn.common.dto.movie.MovieInfoDTO>>)
in Map cannot be applied
to
(java.util.Map<java.lang.Long,capture<? extends com.jonki.popcorn.common.dto.movie.MovieInfoDTO>>)
Run Code Online (Sandbox Code Playgroud)
如何更正这种补充地图的方法?