Spring component-scan can't find packages. I think there is a problem with my project directory. I am using Intellij Idea.
My applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="" />
My directory;
Best Answer
By the way, your Maven project structure is incorrect, which is why IntelliJ shows your Java packages as regular directories. Based on the Maven standard directory layout, you need to create
src/main/java
. So, your project structure should look like this:-Now, when you create
src/main/java
, IntelliJ will treatjava
directory as a regular directory (shown as an orange directory icon). To make it a source directory (blue directory icon), go to IntelliJ's Project Structure and addjava
directory as source directory. You should see something like this:-Once
src/main/java
becomes a blue directory icon, assuming the base package you want to scan istr
, go to your Spring XML configuration and change this line to this:-