这是我写的xml
<?xml version="1.0" encoding="UTF-8"?>
<ioc>
<dao>
<type>org.nutz.dao.impl.NutzDao</type>
<args>[{refer:"dataSource"}]</args>
</dao>
<dataSource>
<type>"org.nutz.dao.impl.SimpleDataSource"</type>
<fields>
<jdbcUrl>jdbc:mysql://localhost:5566/nutzbook</jdbcUrl>
<username>root</username>
<password>3.1415926c</password>
</fields>
</dataSource>
</ioc>
java
public class NutzDao {
public static void main(String[] args) {
Ioc ioc = new NutIoc(new XmlIocLoader("dao.xml"));
DataSource ds = ioc.get(DataSource.class);
Dao dao = new NutDao(ds);
ioc.depose();
}
}
报错
2016-8-31 11:1:5.514 WARN [main] !!You are using default SystemLog! Don't use it in Production environment!!
2016-8-31 11:1:5.538 INFO [main] Nutz is licensed under the Apache License, Version 2.0 .
Report bugs : https://github.com/nutzam/nutz/issues
2016-8-31 11:1:5.682 DEBUG [main] Locations for Scans:
[JarResourceLocation [jarPath=E:\UtilsJar\nutz\mysql-connector-java-5.1.37.jar], JarResourceLocation [jarPath=E:\UtilsJar\nutz\druid-1.0.16.jar], FileSystemResourceLocation [root=E:\EclipseWorkSpace\Java\nutzDao\bin], FileSystemResourceLocation [root=E:\EclipseWorkSpace\Java\nutzDao], JarResourceLocation [jarPath=E:\UtilsJar\nutz\nutz-1.b.53.jar]]
2016-8-31 11:1:5.686 DEBUG [main] Found 1 resource by src( dao.xml ) , regex( .+[.]xml$ )
Exception in thread "main" java.lang.RuntimeException: Name of bean is not unique! name=
at org.nutz.lang.Lang.makeThrow(Lang.java:99)
at org.nutz.ioc.loader.xml.XmlIocLoader.paserBean(XmlIocLoader.java:114)
at org.nutz.ioc.loader.xml.XmlIocLoader.<init>(XmlIocLoader.java:77)
at org.nutz.dao.impl.NutzDao.main(NutzDao.java:12)
2016-8-31 11:1:5.708 DEBUG [main] Resolving bean define, name =
2016-8-31 11:1:5.710 DEBUG [main] Resolved bean define, name =