解决方案 »

  1.   

    问题就是,save操作无效,没有打印出Insert……语句,数据库没有数据
      

  2.   

    少贴了个Maven依赖<dependencies>
    <!-- spring data jpa support -->
    <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>1.5.1.RELEASE</version>
    </dependency>
    <!-- mysql driver -->
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.27</version>
    </dependency>
    <!-- jpa hibernate实现 -->
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.3.3.Final</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.3.3.Final</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate.common</groupId>
    <artifactId>hibernate-commons-annotations</artifactId>
    <version>4.0.4.Final</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.0-api</artifactId>
    <version>1.0.1.Final</version>
    </dependency>
    </dependencies>
      

  3.   

    他进去 处理代码方法里了吗。你有后台打印 进去了没。看下public Product createNewProduct(String name, float price) {
            Product product = new Product();
            product.setName(name);
            product.setPrice(price);
            return productDao.save(product);
        }看下进来这里了没
      

  4.   

    public Product createNewProduct(String name, float price) {
            Product product = new Product();
            product.setName(name);
            product.setPrice(price);
            return productDao.save(product);
        } 那这里面的  name 、price 有值吗
      

  5.   

    添加<context:annotation-config />