Tag Archives: Wrong notes

Error note 404 error


got a 404 error when I was running the login interface. At the beginning, I thought it was a database error (because there was no database information printed in the background), so I made crazy mistakes for the database. Generally, a large probability of database error is a statement error, so be careful!
and then the database frame package has a problem (of course, is a very small probability)
carefully compared to find that the database driver has, the database statement is also right, but I wrote the redirection is clearly main.jsp, but he kept skipping main.html.
Then Baidu 404 error reason for the path error, but the path configuration did not find the problem.
Finally, the boss corrected my mistake and found that the click event written on the submit button was: &western nclick = “javascript: window. Location = ‘main. HTML'”, and to have written form form the from, if the words in the wrong circumstances in the submit written &western nclick = “javascript: window. Location = ‘main. HTML'” will perform, form the action in the form will not work, it is only by priority or load sequence, thus can jump in the main. All the time only HTML web page,
and finally the successful login screen.

to review the web. By the way in the XML configuration file:

https://www.cnblogs.com/xxoome/p/5954633.html get ✔
On September 6, another 404 error

was also found after a series of comparison in the database
The big guy’s solution is to clean the project. For efficiency, Eclipse doesn’t check the plug-in every time you start the project. Clean forces Eclipse to check the installed plug-in. We all know that.Java files are run by compiling to.class files, and clean deletes the compiled and generated.class files and redeploys the project.
because the previously incorrect class file is always in the project, the execution is always wrong

Springboot project startup exception – required a single bean, but 2 were found

springboot project startup exception – required a single bean, but 2 were found

    • description
    • detailed error message
    • error analysis
    • why
    • solution

    problem description

    springboot+mybatis, write interface and implementation classes, and use @autowired injection controller, start exception: required a single bean, but 2 were found

    controller interface:

    @RestController
    @RequestMapping("/api/sys/statistic")
    public class StatisticController {
    
        @Autowired
        private ISysAccessLogService iSysAccessLogService;
        
    }
    

    interface and implementation class

    detail error

    APPLICATION FAILED TO START
    Description:

    Field iSysAccessLogService in com.msb.sys.controller.StatisticController required a single bean, but 2 were found:
    – sysAccessLogServiceImpl: defined in file [/Users/ronghuilin/java/msbjava/target/classes/com/msb/sys/service/impl/SysAccessLogServiceImpl.class]
    – ISysAccessLogService: defined in file [/Users/ronghuilin/java/msbjava/target/classes/com/msb/sys/service/ISysAccessLogService.class]

    Action:

    Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

    Disconnected from the target VM, address: ‘127.0.0.1:61739’, transport: ‘socket’

    error analysis

    if you’re prompted, there’s no way to automatically inject iSysAccessLogService at StatisticController.

    @autowired is injected by type by default, and as prompted, my project has two beans of this type, so it cannot be injected automatically.

    The

    error message also suggests a solution:
    1. Use one of the beans with the @primary annotation as the default,
    2. Add @qualifier to the injected property to specify beanName to specify which bean

    to use

    but I’ve only written one implementation class for the interface, and as expected there’s only one bean, which should be fine.

    Reason

    after a roundabout search, I found that I had annotated springboot’s boot class with @mapperscan (” “com”).

    @mapperscan this is the annotation is the Mapper scan annotation for mybatis, and the scope of the scan I specified is the com package.
    mybatis scans the interface under com, generates the implementation class of the interface, and infuses it into spring.
    then spring scans the interface implementation class I wrote, injects spring, and you have two beans.

    solution

    in the springboot project it is recommended to add @mapper directly to the Mapper interface and not to use @mapperscan.

    if you want to use @mapperscan annotations, be careful to configure the scope of the scan to avoid the above problems caused by repeat scan injection of spring beans.