Comments (4)
@1haann much better, thanks.
@Configuration
public class TestConfig {
@Bean
public TestDao testDao(){
return new TestDaoImpl();
}
}
From the original description, I've extracted this. Please review the best practices. Native processing takes decision at build-time. You are exposing a bean of type TestDao
so no handling of autowired fields for TestDaoImpl
will happen as the type is not exposed. Try rewriting it as follows:
@Configuration
public class TestConfig {
@Bean
public TestDaoImpl testDao(){
return new TestDaoImpl();
}
}
For further support, please ask on StackOverflow as this issue tracker is meant for bug reports and enhancements only.
from spring-boot.
@liufangzhou53 please take the time to format the report correctly. Right now it's a dump of various elements that are very hard to read. You can edit your original description. If you need help with formatting, there is https://docs.github.com/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.
from spring-boot.
Hello. First of all, I am not good at English, so please understand. I saw the code and error message of your writing.
@slf4j
public class TestDaoImpl implements TestDao {
@Autowired
private DbTools dbTools;
@Autowired
private TestMapper testMapper;
String tableName ="testtable";
public TestDaoImpl() {
}
// public TestDaoImpl(){
// super.setTableName(tableName);
// }
@Override
public List<Map> getName2(String mkt) {
// DbTools dbTools = new DbTools();
String a = dbTools.FilterDatesrc("getname");
log.info("dbTools=====>"+a);
if ("Y".equals(GlobalInfo.centrally)) {
MultipleDataSource.setDataSourceKey(dbTools.FilterDatesrc("getname", mkt));
} else {
MultipleDataSource.setDataSourceKey(dbTools.FilterDatesrc("getname"));
}
List list = testMapper.getName2();
return list;
}
@Override
public List<TestDto> getName(String mkt) {
return null;
}
}
"java.lang.NullPointerException: null at com.efuture.business.dao.Impl.TestDaoImpl.getName2(TestDaoImpl.java:41)"
This error message seems to be a problem caused by the testDaoImpl class not being registered as bean.
TestDaoImpl class is not registered as bean DI doesn't seem to work successfully for dbTools and testMapper.
I think you should register as Bean through components like @component, @service in TestDaoImpl class.
This is my first comment on someone else's code and I hope the issue is fixed.
from spring-boot.
thanks
from spring-boot.
Related Issues (20)
- Reconsider use of DynamicPropertyRegistry in spring-boot-testcontainers HOT 1
- Migrating to Spring Boot v2 to v3 and Getting ClassNotFoundException for javax.xml.bind.annotation.XmlElement HOT 4
- Use FileSystemOperations rather than Project's sync and copy
- Use ArchiveOperations rather than Project's zipTree
- Maven plugin integration tests cannot run against release local repository
- Maven plugin integration tests cannot run against release local repository
- Maven plugin integration tests cannot run against release local repository
- Use early static registration of EventPublishingContextWrapper in tests HOT 1
- Default Logback config uses deprecated "converterClass" attribute HOT 6
- AnonymousAuthenticationFilter bug HOT 3
- Default Logback config uses deprecated "converterClass" attribute
- Upgrade to ArchUnit 1.3.0
- Upgrade to ArchUnit 1.3.0
- Upgrade to ArchUnit 1.3.0
- New JarLauncher introduced in 3.2 fails to run huge jars. HOT 1
- DefaultErrorAttributes doesn't populate errors for MethodValidationResult HOT 2
- Add support for org.testcontainers.kafka.KafkaContainer HOT 2
- [Regression, 3.3.3] Maven 4 warnings from spring-boot-dependencies
- Inconsistent behavior between `spring.factories` and `AutoConfiguration.improts` on Spring Boot 3.3.x HOT 1
- 3.4.0-M3 hibernate log Database info output issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot.