Java 为什么eclipse向我显示了这个错误,它可以';你没找到一门课吗?

Java 为什么eclipse向我显示了这个错误,它可以';你没找到一门课吗?,java,spring,hibernate,Java,Spring,Hibernate,我使用maven spring hibernate和eclipse进行开发,我尝试将数据插入到我的postgres基础数据中,但我遇到了这个错误 log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment). log4j:WARN Please initialize the log4j system properly. log4j:WARN See htt

我使用maven spring hibernate和eclipse进行开发,我尝试将数据插入到我的postgres基础数据中,但我遇到了这个错误

log4j:WARN No appenders could be found for logger  (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main"   org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'a' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:568)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1108)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:278)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)
at com.App.main(App.java:19)
我不理解这个错误,因为每个东西都是示例和逻辑,这是我的配置文件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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.2.xsd">



       <context:component-scan base-package="java.com" />
       <context:annotation-config />

       <tx:annotation-driven transaction-manager="transactionManager"/>
       <bean id="transactionManager"  
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">  
        <property name="sessionFactory" ref="sessionFactory" />  
    </bean> 

    <bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="org.postgresql.Driver" />
    <property name="url" value="jdbc:postgresql://localhost:5432/webservices" />
    <property name="username" value="postgres" />
    <property name="password" value="1234" />
</bean>
    <bean id="sessionFactory"    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="java.com" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>
</bean>
</beans>
这是我班的主要课程

package com;

import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;

 import com.entity.Ws_security;
 import com.services.Interface_ws_security_services;

 public class App {




public static void main(String[] args) {

    @SuppressWarnings("resource")
    ApplicationContext ctx1 = new ClassPathXmlApplicationContext("spring_hibernate.xml");

    Interface_ws_security_services service=(Interface_ws_security_services)    ctx1.getBean("a");

    Ws_security ess=new Ws_security();
    ess.setIDws("ess1");
    ess.setLogin("ess2");
    service.addws(ess);
    System.out.println("Done");


}

    }

请说明我的问题是什么,如果有人找到了解决方案,请将其写出来

<context:component-scan base-package="java.com" />
修复上下文配置,并根据约定选择一个更好的包名称:

package com.mydomainname.myapplication

Spring在包java.com中搜索注释服务

<context:component-scan base-package="java.com" />

你的服务包是什么


包“com”的名称选择不当。请参见

抱歉,我不理解ycom.dao com.entity com.services此my package将基本包更改为base package=“com”而不是java.com我在代码示例中遗漏了一个空格,这使其不可见。您的问题标题“为什么eclipse向我显示了这个错误,而它却找不到一个类?”表明您在理解上还有另一个问题:--1)引起错误的不是eclipse,而是spring!--2)它并没有说找不到一个类,而是说找不到一个名为“a”的bean(这是两个真正不同的概念)。
package com.mydomainname.myapplication
<context:component-scan base-package="java.com" />