第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Spring 數(shù)據(jù) JDBC 無(wú)法創(chuàng)建存儲(chǔ)庫(kù) Bean -

Spring 數(shù)據(jù) JDBC 無(wú)法創(chuàng)建存儲(chǔ)庫(kù) Bean -

瀟湘沐 2022-06-30 11:39:00
我剛剛開(kāi)始探索 Spring Data JDBC。我有一個(gè)簡(jiǎn)單的數(shù)據(jù)庫(kù)(postgres),其中包含我要查詢(xún)的問(wèn)卷表:CREATE TABLE IF NOT EXISTS foster.questionnaires (    questionnaire_id SERIAL PRIMARY KEY,    version varchar(10),    name text,    title text,    description text,    status questionnaire_status_types);和 Java 類(lèi):(配置靈感來(lái)自這里)@SpringBootApplication(scanBasePackages= {"com.app.foster"})@EnableJdbcRepositories("com.app.foster.dal.repositories")public class FosterApplication extends JdbcConfiguration {    // Config    @Bean    NamedParameterJdbcOperations operations() {        return new NamedParameterJdbcTemplate(dataSource());    }    @Bean    PlatformTransactionManager transactionManager() {        return new DataSourceTransactionManager(dataSource());    }    @Value("${spring.datasource.url}")    private String url;    @Bean    @ConfigurationProperties("spring.datasource")    public HikariDataSource dataSource() {        //User name and password is fetched from some other data storage        HikariConfig hikariConfig = new HikariConfig();        hikariConfig.setJdbcUrl(url);        hikariConfig.setUsername("postgres"); //TODO: abstract these        hikariConfig.setPassword("password");        //The data source created here doesn't have connection timeout value        //set by me        return new HikariDataSource(hikariConfig);    }    @Bean    public ApplicationListener<?> loggingListener() {        return (ApplicationListener<ApplicationEvent>) event -> {            if (event instanceof RelationalEvent) {                System.out.println("Received an event: " + event);            }         };    }    public static void main(String[] args) {        SpringApplication.run(FosterApplication.class, args);    } }(實(shí)體)@Entity@Table(name="questionnaires")public class Questionnaire {  @Id  Long questionnaire_id;  String version;  String name;  String title;  String description;    }
查看完整描述

2 回答

?
慕容3067478

TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個(gè)贊

通過(guò)一些實(shí)驗(yàn)找到了修復(fù):

事實(shí)證明我收到了錯(cuò)誤

entity is marked @NonNull but is null

因?yàn)槲以噲D查詢(xún)的實(shí)體有一個(gè) postgresql 枚舉類(lèi)型列,我用 java 代碼中的枚舉表示(我猜因此實(shí)體沒(méi)有解析?)...將字段更改為 String 列解決了問(wèn)題。也許這里的錯(cuò)誤信息可以細(xì)化...


查看完整回答
反對(duì) 回復(fù) 2022-06-30
?
BIG陽(yáng)

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊

我想,你必須為你的實(shí)體實(shí)現(xiàn)默認(rèn)構(gòu)造函數(shù)。 https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.8.9


查看完整回答
反對(duì) 回復(fù) 2022-06-30
  • 2 回答
  • 0 關(guān)注
  • 162 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)