전에는 문제 없이 실행되던 프로젝트였는데 다시 실행하려고 보니
servlet-context.xml 파일의 classpath 가 없다는 것.
[classpath:/mybatis/mapper/*.xml]: class path resource [mybatis/mapper/] cannot be resolved to URL because it does not exist
검색을 해보니 해결하는 다양한 방법이 있었다.
나는 둘다 안돼고 유형2 같은경우 해당 단계는 넘어가지만 추후에 해당 서비스의 맵퍼파일에 접근하려고 할때 아래와 같은 또 다른 에러와 마주했다.
org.apache.ibatis.binding.BindingException: Type interface
mybatis.MainImplis not known to the MapperRegistry.
그래서 classpath*: 는 적용하지 않으면서 근본적인 해결책을 찾은 방법을 기록한다.
classpath 경로는 변경그대로 두고 ,
pom.xml 의 안에 내용을 추가하면 된다.
위치는 위에 위치하면된다.
<!-- Mybatis 빈 생성 -->
<beans:bean id="sqlSessionFactory"
class="org.mybatis.spring.SqlSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource"/>
<beans:property name="mapperLocations"
value="classpath:mybatis/mapper/*.xml"/>
</beans:bean>
<!-- pom.xml -->
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
...
</plugins>
</build>
삽질 말고 개발을 하고싶은 하루....