java吧 关注:1,241,624贴子:12,712,749
  • 6回复贴,共1

吧里还有懂JAVA的吗?

只看楼主收藏回复

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project bos_management: Compilation failure
[ERROR] /D:/develop/IDEA/bos_2.0/bos_management/src/main/java/cn/itcast/bos/service/base/impl/OrderServiceImpl.java:[143,31] 无法从静态上下文中引用非静态 方法 findByOrderNum(java.lang.String)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
有没有大佬懂的


IP属地:江苏1楼2018-08-03 17:48回复
    ServiceImpl中:
    @Override
    public Order findByOrderNum(String orderNum) {
    return OrderRepository.findByOrderNum(orderNum);
    }
    准确的说这个方法报错


    IP属地:江苏2楼2018-08-03 17:49
    回复
      Dao代码
      public interface OrderRepository extends JpaRepository<Order,Integer> {
      Order findByOrderNum(String orderNum);
      }


      IP属地:江苏4楼2018-08-03 17:49
      回复
        有没有懂的,请赐教不胜感谢


        IP属地:江苏5楼2018-08-03 17:51
        回复
          orderrepository.findbyordernum怎么能这样调用findbyordernum方法呢,eclipse没有红色波浪线提示吗?springdata应该先autowire一个orderrepository的实例,然后通过这个实例调用方法,而不是直接类名.方法名()


          IP属地:浙江来自Android客户端6楼2018-08-03 17:57
          回复
            中文都给你打出来了“无法从静态上下文中引用非静态 方法”,让你先实例化在调用


            IP属地:四川8楼2021-04-03 01:24
            回复