IDEAL+Maven+Spring MVC+Java Web creation process

Create operations with pictures and texts

I’m using the Ideal Enterprise Edition, and the community version should be different for students.

First create a new Maven project:
Insert picture description here
right-click the project name after opening it, add a framework, select Spring MVC and Java Web:
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
click OK and wait for the download to complete. I didn't have the option of Spring MVC when I added the Spring framework (pictured), just uninstall and add the response component in FileSettingPlugins . At this time, configure the Tomcat server and it can run theoretically .
Insert picture description here
Insert picture description here

Notice that there is a Fix in the lower right corner , click to jump to this page:

Insert picture description here

Scroll down to see this:

Insert picture description here

After running, you can see Url with the above address in the browser. This mode of development mode can be hot replaced, and you can refer to relevant information for specific details. However, there is a pit to access the address. You can directly replace / wr_war_exploded with / . At this time, the running triangle should be green, and the following error may be reported after clicking:

 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal 一个或多个listeners启动失败,更多详细信息查看对应的容器日志文件
 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal 由于之前的错误,Context[/wr_war_exploded]启动失败

This is because our dependencies have not been configured yet and need to be added manually: FileProject StructureArtifacts

Insert picture description here

Each item can be added by clicking twice. Click the green triangle again to find that the operation is successful.

Insert picture description here

I also want to nag here. In just Project Structure inside, Project and Modules in the sdk may not be the same. If your project can run successfully just now, you don't need to modify it temporarily. If there is an error that no longer supports source option 5, please use version 6 or higher. Release version 5 is not supported
Insert picture description here
Insert picture description here

The solution is to adjust to the same, and then open SettingBuild, Execution...CompilerJava Compiler , all adjusted to the same.
Insert picture description here

The above solution is a bit cumbersome, you can also pom.xmladd this directly , and change the java version to your own:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
        <java.version>11</java.version>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
</properties>  

How to view java version:
Insert picture description here

Project structure analysis

Before starting, I assume that you know a general idea about MVC. Now we look at the directory structure, it should look like this:

Insert picture description here

The blue java folder is used to store the so-called back-end code, corresponding to M and C in MVC. The web folder is used to store front-end resources, and the content in the WEB-INF folder is protected and should not be directly accessed. The second file dispatcher-servlet.xml is a configuration file used to configure the routing of the project. The page jump is forwarded by it. The first file applicationContext.xml is also a configuration file, used to configure other Spring services, such as database control. The web.xml file will not be introduced.

This article introduces the most basic Spring MVC creation process, which also has several pitfalls. I hope that everyone will not encounter too much resistance at the beginning, and more energy will be used to learn principles and techniques rather than operations.

Guess you like

Origin blog.csdn.net/qq_42893430/article/details/112118203