Idea 学习笔记

学习娱乐笔记

1.idea 创建一个 项目->devicemanager

   遇到的问题:1.设置tomcat 的时候,no  artifact configered

添加之后就可以了。

2.hello world 跑不起来

可以看到白色字体的错误:com.intellij.execution.ExecutionException: D:\Ide\work-space\device_manager\out\artifacts\Devicemanager not found for the web module.

解决办法:

 

确定的时候好像有一个警告,点fix

 3.这些做完之后运行,一直404,找不到界面

 

我的是这个路径错误了

 

不知道为什么默认的路径是下面那个 web,改成src->main 里面的之后再运行就好了。下面那个web没有存在的必要,删除!

 

总算是爬出了 hello world 的坑,一般不需要自己创建项目,都是别人配置完之后直接跑,但是自己玩的话->心累。

4.配置SSM SpringMvc +Spring +Mybatis

 

进去之后选spring 和它下面的springmvc

配置一下web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

  <display-name>Archetype Created Web Application</display-name>

  <!--welcome pages-->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

  <!--配置springmvc DispatcherServlet-->
  <servlet>
    <servlet-name>springMVC</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <!--配置dispatcher.xml作为mvc的配置文件-->
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
  </servlet>
  <servlet-mapping>
    <servlet-name>springMVC</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  <!--把applicationContext.xml加入到配置文件中-->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
</web-app>

 上面是从网上抄的

dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <!--此文件负责整个mvc中的配置-->

    <!--启用spring的一些annotation -->
    <context:annotation-config/>

    <!-- 配置注解驱动 可以将request参数与绑定到controller参数上 -->
    <mvc:annotation-driven/>

    <!--静态资源映射-->
    <!--本项目把静态资源放在了webapp的statics目录下,资源映射如下-->
    <mvc:resources mapping="/css/**" location="/WEB-INF/statics/css/"/>
    <mvc:resources mapping="/js/**" location="/WEB-INF/statics/js/"/>
    <mvc:resources mapping="/image/**" location="/WEB-INF/statics/image/"/>

    <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀(如果最后一个还是表示文件夹,则最后的斜杠不要漏了) 使用JSP-->
    <!-- 默认的视图解析器 在上边的解析错误时使用 (默认使用html)- -->
    <bean id="defaultViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/view/"/><!--设置JSP文件的目录位置-->
        <property name="suffix" value=".jsp"/>
        <property name="exposeContextBeansAsAttributes" value="true"/>
    </bean>

    <!-- 自动扫描装配 -->
    <context:component-scan base-package="com.dev_manager.controller"/>
</beans>

弄完之后报错 说 URI not registered,网上查了好多,有人说alt+enter ->fetch 就好了,但是那个spring-context.xsd 我获取不到,最后发现我所有pom添加的依赖都没有引入进来、

勾了自动导入之后就行了 

5.创建jdbc.properties 由于之前是创建的file 文件,不是选的 resbundle ,导致后面引入的时候说 资源不匹配。

对比下 log4j 的配置,两个文件的区别一目了然,本想删了重建,但是删了之后创建resbundle 的时候永远提示 文件已存在,然后自动给我生成一个新的,没办法,只好suppress,让它不要报红,报红看着挺难受的

6.静态资源映射

<!--本项目把静态资源放在了webapp的statics目录下,资源映射如下-->
    <mvc:resources mapping="/css/**" location="/WEB-INF/statics/css/"/>
    <mvc:resources mapping="/js/**" location="/WEB-INF/statics/js/"/>
    <mvc:resources mapping="/image/**" location="/WEB-INF/statics/image/"/>
    <mvc:resources mapping="/lib/**" location="/WEB-INF/statics/lib/"/>

用的时候直接 /css/ 就好了

 

总结:这个hello world 程序比android 复杂多了,要手动配置很多东西,感觉其实可以做一个插件,创建项目的时候自动生成这些配置项和配置文件,因为每个公司都有自己的后台模式,但使用一套东西总比下面的人胡乱配置要好。

爬出了hello world 的坑了,可是自己写项目的话,包括了 数据库设计,页面设计,想想都不想写了。万事开头难,慢慢来吧,一着急都想放弃了,希望有一天可以  后台+前端+移动端 发表自己的个人项目,而不是想写个程序发现要后台。

顺便吐槽公司后台,难产,app基本做完半年了,后台还没动静,马上交货了,还没有一个能看的界面,让我做个自动更新功能,数据都没有,完全用不了吧。算了,想想我只是个小兵,应该不会在这里多久了。兵熊熊一个,将熊熊一窝,下次希望找个靠谱的领导。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值