0
我有一個返回數據的基礎上的客戶端實例的Groovy類:創建從一個Groovy類一個Spring bean導致「找不到符號錯誤」
class DBClient {
private static DBClient INSTANCE
private String url
private String userName
private String password
private String driver
@Synchronized
static DBClient getInstance() {
if (!INSTANCE) {
INSTANCE = new DBClient()
}
return INSTANCE
}
Sql sql = Sql.newInstance(url, userName, password, driver)
void setUrl(String url) {
this.url = url
}
void setUserName(String userName) {
this.userName = userName
}
void setPassword(String password) {
this.password = password
}
void setDriver(String driver) {
this.driver = driver
}
def getAllSaa() {
sql.rows("select * from Saa")
}
}
我嘗試創建這個類的一個bean在@Configuration類:
@Configuration
@Profile("prod")
public class OracleServerConfiguration {
@Bean
public DBClient dbClient() {
DBClient dbClient = DBClient.getInstance();
dbClient.setUrl("jdbc:oracle:thin:@localhost:1521:xe");
dbClient.setUserName("SYSTEM");
dbClient.setPassword("1111");
dbClient.setDriver("oracle.jdbc.OracleDriver");
return dbClient;
}
}
它看起來的IntelliJ好的,但是當我嘗試建立與gradle這個項目,我得到一個錯誤
「OracleServerConfiguration.java:14:錯誤:無法找到符號 DBClient dbClient = DBClient.getInstance();符號:類dbclient中的位置:。。?類OracleServerConfiguration」
我試圖在dbclient中類中的所有字段創建getter和setter方法,但都無濟於事
是否有人有從Groovy類創建豆類經驗