Intellij idea 尝试使用intellij中的spring mybatis项目获取示例petstore
我已经从下载了样本 1) 然后打开pom.xml并将其导入intellij 2) 我添加了一个SpringMVC方面 3) 我添加了一个web方面 4) 我正在使用intellij 12.1.6 一旦完成,自动布线将失败。我正在努力学习这个新的框架 所有服务自动连线都有类似以下错误: 无法自动连线。未找到“LineItemMapper”类型的beanIntellij idea 尝试使用intellij中的spring mybatis项目获取示例petstore,intellij-idea,Intellij Idea,我已经从下载了样本 1) 然后打开pom.xml并将其导入intellij 2) 我添加了一个SpringMVC方面 3) 我添加了一个web方面 4) 我正在使用intellij 12.1.6 一旦完成,自动布线将失败。我正在努力学习这个新的框架 所有服务自动连线都有类似以下错误: 无法自动连线。未找到“LineItemMapper”类型的bean public class OrderService { @Autowired private ItemMapper itemMapper
public class OrderService {
@Autowired
private ItemMapper itemMapper;
@Autowired
private OrderMapper orderMapper;
@Autowired
private SequenceMapper sequenceMapper;
@Autowired
private LineItemMapper lineItemMapper;
我认为这是我在项目中设置不正确的地方
这是示例中提供的applicationCOntext
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!-- in-memory database and a datasource -->
<jdbc:embedded-database id="dataSource">
<jdbc:script location="classpath:database/jpetstore-hsqldb-schema.sql"/>
<jdbc:script location="classpath:database/jpetstore-hsqldb-dataload.sql"/>
</jdbc:embedded-database>
<!-- transaction manager, use JtaTransactionManager for global tx -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- enable component scanning (beware that this does not enable mapper scanning!) -->
<context:component-scan base-package="org.mybatis.jpetstore.service" />
<!-- enable autowire -->
<context:annotation-config />
<!-- enable transaction demarcation with annotations -->
<tx:annotation-driven />
<!-- define the SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="org.mybatis.jpetstore.domain" />
</bean>
<!-- scan for mappers and let them be autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.mybatis.jpetstore.persistence" />
</bean>
</beans>
这是该项目的一部分
希望有人能指出我做错了什么
感谢您的帮助首先要做的是尝试使用本周早些时候发布的最新版本的IntelliJ。它改进了对spring的支持
潜在的问题是您需要设置IntelliJ的spring方面并分配应用程序上下文组 谢谢,我不知道什么时候可以升级到v13。当查看我的spring方面时,我配置了spring-config.xml和applicationContext.xml。刚升级到v13,仍然存在相同的问题尝试转到项目结构,找到您正在使用的模块并添加spring方面。然后单击镶嵌面面板(右侧)左下角的+按钮。选择与此模块关联的上下文文件,然后单击“确定”。不确定我是否在跟踪。所以在左边,在project选项卡下有一个Structure选项卡,当我选择一个行项目时,它会在config xml中显示相关的项目。