When I debug the JdbcTemplate sourcecode use IDEA,the IDE tips me:'Source code does not match the bytecode'
Screenshot:
and i use mvn to manage my project;my maven pom config is:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.orm</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
This can also happen if you have multiple dependencies that themselves have different versions of the same dependency. This post on the JetBrains site shows how to enable the alternate source switcher in preferences.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206822215-what-does-Choose-Sources-do-and-how-can-I-undo-what-it-does-
Intellij gives a such warning when compiled code doesn't match the source code, i.e. you try to debug the code but it has changed and not rebuilt.
Make sure after you imported your code you didn't modify it. If you modify then first build/compile it before starting the debugger.
For example below code will cause this warning :-
public class HelloSO {
public static void main(String[] args) {
System.out.println("First time source code");
}
}
Now you compiled above class and start debugging it, everything works fine.
But after that you add one more print statement and try to put the debug point on that line without re-compile it, then in this case as byte code for new line is not generated, hence you will get same warning from IntelliJ.
After viewing the other similar questions and answers on this problem, none of which helped me. What solved the problem was simply adding a dependency. In my case I ran into this issue when I was attempting to debug org.springframework.web.servlet.DispatcherServlet. I finally noticed that IntelliJ could not find javax.servlet in my imports.
In my Maven project, I added
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0.1</version>
</dependency>
to my pom.xml which solved the problem.
Double check that all of your imports are being resolved.
For me this issue was arising because I'd made changes to my source code but had not yet deployed them to the target device. It still allowed me to set up the debugging which was confusing, but then gave me this error.
To fix:
After rebuilding / redeploying, your debug and deployed code will match up and you shouldn't get any more errors! Just a matter of matching up the two binaries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With