Coder Social home page Coder Social logo

springboot-exercise's People

Contributors

bohub12 avatar

Stargazers

 avatar

Watchers

 avatar

springboot-exercise's Issues

[MyBatis] org.apache.ibatis.reflection.ReflectionException: There is no getter for property ...

MyBatis로 insert 쿼리를 실행한 결과 위와 같은 exception이 발생했다.
정확한 에러 메시지와 Mapper, ArticleMapper.xml 파일은 다음과 같다.

// 에러메시지
org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'contentType' in 'class com.example.demo.article.domain.Article'
	at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:387) ~[mybatis-3.5.13.jar:3.5.13]
	at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:162) ~[mybatis-3.5.13.jar:3.5.13]
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:159) ~[mybatis-3.5.13.jar:3.5.13]
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:49) ~[mybatis-3.5.13.jar:3.5.13]
	at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:116) ~[mybatis-3.5.13.jar:3.5.13]
	at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122) ~[mybatis-3.5.13.jar:3.5.13]
<insert id="saveArticle" parameterType="map" useGeneratedKeys="true">
    INSERT INTO ARTICLE (title, author, content_type, content)
        VALUES (#{article.title}, #{article.author}, #{article.contentType}, #{article.content});
</insert>
// ArticleMapper.java

@Mapper
public interface ArticleMapper {
    Article getArticle(@Param("id") Long id);
    void saveArticle(@Param("article") Article article);
}

원인 분석

에러메시지 그래도 해석하면 Enum type인 contentType 필드에 접근하지 못했다는 뜻이다. 다만 실제로 Article 클래스에는 @getter가 있으므로 필드에 접근할 수 있다. 그럼 어디서 에러가 발생한걸까?

해결방법

거창한 이유가 있을 줄 알고, 설렜지만 필드명을 잘못적었다 ㅎㅎㅎ...; article.articleContent.contentType 으로 수정해주니 해당 에러메시지는 뜨지 않았다.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.