Intellij IDEA bug?

对于如下给出的SSM简单的project,如何运行。该项目只有一个Gradle的配置文件和SSM的源文件以及配置文件。

D:\N3verL4nd\Desktop\SSM>tree /f src
卷 本地磁盘 的文件夹 PATH 列表
卷序列号为 00000200 0006:08B0
D:\N3VERL4ND\DESKTOP\SSM\SRC
├─main
│  ├─java
│  │  └─cn
│  │      └─bjut
│  │          ├─controller
│  │          │      PersonController.java
│  │          │
│  │          ├─entity
│  │          │      Person.java
│  │          │
│  │          ├─mapper
│  │          │      PersonMapper.java
│  │          │
│  │          └─service
│  │              │  PersonService.java
│  │              │
│  │              └─impl
│  │                      PersonServiceImpl.java
│  │
│  ├─resources
│  │  │  applicationContext.xml
│  │  │  jdbc.properties
│  │  │  log4j.properties
│  │  │  mybatis-config.xml
│  │  │  mybatis-generator.xml
│  │  │  rebel.xml
│  │  │  springmvc.xml
│  │  │
│  │  └─cn
│  │      └─bjut
│  │          └─mapper
│  │                  PersonMapper.xml
│  │
│  └─webapp
│      │  index.jsp
│      │
│      └─WEB-INF
│          │  c.tld
│          │  web.xml
│          │
│          └─views
│                  hello.jsp
│                  test.jsp
│
└─test
    ├─java
    │      T.java
    │
    └─resources

D:\N3verL4nd\Desktop\SSM>

build.gradle

group 'com.xiya'
version '1.0-SNAPSHOT'

apply plugin: 'idea'
apply plugin: 'war'

sourceCompatibility = 1.8

buildscript {
    repositories {
        maven {
            url 'http://maven.aliyun.com/nexus/content/groups/public/'
        }
    }
    dependencies {
        classpath "gradle.plugin.org.akhikhl.gretty:gretty:+"
    }
}

apply plugin: "org.akhikhl.gretty"

repositories {
    maven {
        url 'http://maven.aliyun.com/nexus/content/groups/public/'
    }
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.40'
    compile group: 'org.springframework', name: 'spring-context', version: '4.3.9.RELEASE'
    compile group: 'org.springframework', name: 'spring-jdbc', version: '4.3.9.RELEASE'
    compile group: 'org.springframework', name: 'spring-webmvc', version: '4.3.9.RELEASE'
    compile group: 'org.mybatis', name: 'mybatis', version: '3.4.4'
    compile group: 'org.mybatis', name: 'mybatis-spring', version: '1.3.1'
    compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.1.1'
    compile group: 'log4j', name: 'log4j', version: '1.2.17'
//    providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
    providedCompile group: 'javax.servlet', name: 'jstl', version: '1.2'
}

tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
}
我们使用Gradle生成IDEA环境。-->cmd下执行gradle idea



使用IDEA打开(打开SSM.ipr)

2017/6/17
19:03	Unlinked Gradle project?
			Import Gradle project, this will also enable Gradle Tool Window.
			Don't want to see the message for the project again: press here.

19:03	Frameworks detected: Web framework is detected in the project Configure

19:03	Spring Configuration Check
			Unmapped Spring configuration files found.
			Please configure Spring facet or use 'Create Default Context' to add one including all unmapped files.
			SSM (2 files)   Create Default Context
			Show Help Disable...
如上提示,需要配置gradle环境



配置jetty运行下。


E:\t00ls\Merry>curl http://localhost:8080/SSM/



<html>
<head>
    <title>Title</title>
</head>
<body>
    <a href="/SSM/test1;jsessionid=16o5sh26vkjna1kvjl60vspa78">test</a>
</body>
</html>

E:\t00ls\Merry>
如上配置是能够正确运行的。

但是存在一个提示还没解决:

Intellij IDEA未能找到Spring的配置文件。

这也导致了:

Controller未能识别

未能找到jsp视图文件

加入使用如下方式(Create Default Context),也不能解决该问题。


试验了很多次,找到一个解决方法:

打开Project Structure-->Project Settings-->Moudles

选中XXX_main文件夹,点击上边绿色的加号选择Spring


然后勾选下列选项就可以解决问题了。




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

N3verL4nd

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值